diff options
author | Pranav P | 2023-05-24 14:23:33 +0530 |
---|---|---|
committer | Pranav P | 2023-05-24 14:23:33 +0530 |
commit | 6ae708e34a0c38ee73acabf3af98deaac62e6cd6 (patch) | |
tree | 417fcdc37f63dc9f8d2c306ffaef767062c4f709 /src/frontEnd/TerminalUi.py | |
parent | 061af1b876ed0cb5ca3ad8a2a55c3b9052e00b29 (diff) | |
download | eSim-6ae708e34a0c38ee73acabf3af98deaac62e6cd6.tar.gz eSim-6ae708e34a0c38ee73acabf3af98deaac62e6cd6.tar.bz2 eSim-6ae708e34a0c38ee73acabf3af98deaac62e6cd6.zip |
Changed the name progressBar to TerminalUi
Diffstat (limited to 'src/frontEnd/TerminalUi.py')
-rw-r--r-- | src/frontEnd/TerminalUi.py | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/src/frontEnd/TerminalUi.py b/src/frontEnd/TerminalUi.py new file mode 100644 index 00000000..b5f7a836 --- /dev/null +++ b/src/frontEnd/TerminalUi.py @@ -0,0 +1,154 @@ +from PyQt5 import QtCore, QtGui, QtWidgets +import os + + +class Ui_Form(object): + def __init__(self, qProcess): + self.qProcess = qProcess + self.iconDir = "../../images" + # super().__init__() + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(1244, 644) + self.verticalLayoutWidget = QtWidgets.QWidget(Form) + self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 10, 1131, 471)) + self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") + self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget) + self.verticalLayout.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint) + self.verticalLayout.setContentsMargins(15, 15, 15, 15) + self.verticalLayout.setObjectName("verticalLayout") + self.horizontalLayout = QtWidgets.QHBoxLayout() + self.horizontalLayout.setContentsMargins(-1, -1, -1, 0) + self.horizontalLayout.setSpacing(6) + self.horizontalLayout.setObjectName("horizontalLayout") + self.terminalUi = QtWidgets.QProgressBar(self.verticalLayoutWidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.terminalUi.sizePolicy().hasHeightForWidth()) + self.terminalUi.setSizePolicy(sizePolicy) + self.terminalUi.setMaximumSize(QtCore.QSize(16777215, 35)) + self.terminalUi.setStyleSheet("QProgressBar::chunk {\n" +" background-color: rgb(54,158,225);\n" +"}") + self.terminalUi.setMaximum(0) + self.terminalUi.setProperty("value", -1) + self.terminalUi.setFormat("") + self.terminalUi.setObjectName("progressBar") + self.horizontalLayout.addWidget(self.terminalUi) + self.redo_simulation_button = QtWidgets.QPushButton(self.verticalLayoutWidget) + self.redo_simulation_button.setMaximumSize(QtCore.QSize(16777215, 35)) + self.redo_simulation_button.setObjectName("redo_simulation_button") + self.horizontalLayout.addWidget(self.redo_simulation_button) + self.cancel_simulation_button = QtWidgets.QPushButton(self.verticalLayoutWidget) + self.cancel_simulation_button.setMaximumSize(QtCore.QSize(16777215, 35)) + self.cancel_simulation_button.setObjectName("cancel_simulation_button") + self.horizontalLayout.addWidget(self.cancel_simulation_button) + self.light_dark_mode_button = QtWidgets.QPushButton(self.verticalLayoutWidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.light_dark_mode_button.sizePolicy().hasHeightForWidth()) + self.light_dark_mode_button.setSizePolicy(sizePolicy) + self.light_dark_mode_button.setMaximumSize(QtCore.QSize(35, 35)) + self.light_dark_mode_button.setText("") + self.light_dark_mode_button.setObjectName("light_dark_mode_button") + self.horizontalLayout.addWidget(self.light_dark_mode_button) + self.verticalLayout.addLayout(self.horizontalLayout) + self.simulationConsole = QtWidgets.QTextEdit(self.verticalLayoutWidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.simulationConsole.sizePolicy().hasHeightForWidth()) + self.simulationConsole.setSizePolicy(sizePolicy) + self.simulationConsole.setMinimumSize(QtCore.QSize(0, 400)) + self.simulationConsole.setStyleSheet("QTextEdit {\n" +" background-color: rgb(36, 31, 49);\n" +" color: white;\n" +"}") + self.simulationConsole.setTextInteractionFlags(QtCore.Qt.NoTextInteraction) + self.simulationConsole.setObjectName("simulationConsole") + self.verticalLayout.addWidget(self.simulationConsole) + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Form")) + self.redo_simulation_button.setText(_translate("Form", "Redo Simulation")) + self.cancel_simulation_button.setText(_translate("Form", "Cancel Simulation")) + self.simulationConsole.setHtml(_translate("Form", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" +"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" +"p, li { white-space: pre-wrap; }\n" +"</style></head><body style=\" font-family:\'Ubuntu\'; font-size:11pt; font-weight:400; font-style:normal;\">\n" +"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The quick brown fox jumped over the lazy dog</p></body></html>")) + + self.simulationConsole.setText("") + + self.dark_color = True + self.light_dark_mode_button.setIcon(QtGui.QIcon(os.path.join(self.iconDir, 'light_mode.png'))) + self.light_dark_mode_button.clicked.connect(self.changeColor) + + self.cancel_simulation_button.clicked.connect(self.cancelSimulation) + self.redo_simulation_button.clicked.connect(self.redoSimulation) + + def writeIntoConsole(self, consoleLog): + self.simulationConsole.insertPlainText(consoleLog) + + def writeSimulationStatusToConsole(self, isSuccess): + failedFormat = '<span style="color:#ff3333;">{}</span>' + successFormat = '<span style="color:#00ff00;">{}</span>' + + if self.qProcess.exitStatus() == QtCore.QProcess.NormalExit: + if isSuccess: + self.simulationConsole.append(successFormat.format("Simulation Completed Successfully!")) + else: + self.simulationConsole.append(failedFormat.format("Simulation Failed!")) + + def scrollConsoleToBottom(self): + scrollLength = self.simulationConsole.verticalScrollBar().maximum() + self.simulationConsole.verticalScrollBar().setValue(scrollLength) + + def showProgressRunning(self): + self.terminalUi.setMaximum(0) + self.terminalUi.setProperty("value", -1) + + def showProgressCompleted(self): + self.terminalUi.setMaximum(100) + self.terminalUi.setProperty("value", 100) + + def cancelSimulation(self): + if (self.qProcess.state() == QtCore.QProcess.NotRunning): + return + cancelFormat = '<span style="color:#3385ff;">{}</span>' + self.qProcess.kill() + self.showProgressCompleted() + self.simulationConsole.append(cancelFormat.format("Simulation Cancelled!")) + self.scrollConsoleToBottom() + + def setNgspiceArgs(self, args): + self.args = args + + def redoSimulation(self): + if (self.qProcess.state() == QtCore.QProcess.Running): + return + self.showProgressRunning() + self.simulationConsole.setText("") + self.qProcess.start('ngspice', self.args) + + def changeColor(self): + if self.dark_color is True: + self.simulationConsole.setStyleSheet("QTextEdit {\n" + " background-color: white;\n" + " color: black;\n" + "}") + self.light_dark_mode_button.setIcon(QtGui.QIcon(os.path.join(self.iconDir, "dark_mode.png"))) + self.dark_color = False + else: + self.simulationConsole.setStyleSheet("QTextEdit {\n" + " background-color: rgb(36, 31, 49);\n" + " color: white;\n" + "}") + self.light_dark_mode_button.setIcon(QtGui.QIcon(os.path.join(self.iconDir, "light_mode.png"))) + self.dark_color = True
\ No newline at end of file |