diff options
-rw-r--r-- | src/frontEnd/TerminalUi.py | 116 | ||||
-rw-r--r-- | src/frontEnd/TerminalUi.ui | 163 | ||||
-rw-r--r-- | src/ngspiceSimulation/NgspiceWidget.py | 12 |
3 files changed, 196 insertions, 95 deletions
diff --git a/src/frontEnd/TerminalUi.py b/src/frontEnd/TerminalUi.py index ecf93ee2..2d6493d7 100644 --- a/src/frontEnd/TerminalUi.py +++ b/src/frontEnd/TerminalUi.py @@ -1,98 +1,36 @@ -from PyQt5 import QtCore, QtGui, QtWidgets +from PyQt5 import QtCore, QtGui, QtWidgets, uic import os - -class Ui_Form(object): +class TerminalUi(QtWidgets.QMainWindow): def __init__(self, qProcess, args): + super(TerminalUi, self).__init__() + + #Other variables + self.darkColor = True self.qProcess = qProcess self.args = args 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.progressBar = QtWidgets.QProgressBar(self.verticalLayoutWidget) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.progressBar.sizePolicy().hasHeightForWidth()) - self.progressBar.setSizePolicy(sizePolicy) - self.progressBar.setMaximumSize(QtCore.QSize(16777215, 35)) - self.progressBar.setStyleSheet("QProgressBar::chunk {\n" -" background-color: rgb(54,158,225);\n" -"}") - self.progressBar.setMaximum(0) - self.progressBar.setProperty("value", -1) - self.progressBar.setFormat("") - self.progressBar.setObjectName("progressBar") - self.horizontalLayout.addWidget(self.progressBar) - 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 setupUi(self, Form): + #Load the ui file + uic.loadUi("TerminalUi.ui", self) - 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>")) + #Define Our Widgets + self.progressBar = self.findChild(QtWidgets.QProgressBar, "progressBar") + self.simulationConsole = self.findChild(QtWidgets.QTextEdit, "simulationConsole") - self.simulationConsole.setText("") + self.lightDarkModeButton = self.findChild(QtWidgets.QPushButton, "lightDarkModeButton") + self.cancelSimulationButton = self.findChild(QtWidgets.QPushButton, "cancelSimulationButton") + self.redoSimulationButton = self.findChild(QtWidgets.QPushButton, "redoSimulationButton") - 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) + #Add functionalities to Widgets + self.lightDarkModeButton.setIcon(QtGui.QIcon(os.path.join(self.iconDir, 'light_mode.png'))) + self.lightDarkModeButton.clicked.connect(self.changeColor) + self.cancelSimulationButton.clicked.connect(self.cancelSimulation) + self.redoSimulationButton.clicked.connect(self.redoSimulation) - self.cancel_simulation_button.clicked.connect(self.cancelSimulation) - self.redo_simulation_button.clicked.connect(self.redoSimulation) + #show app + self.show() def writeSimulationStatusToConsole(self, isSuccess): """Writes simulation status to the console with appropriate style @@ -143,17 +81,17 @@ class Ui_Form(object): def changeColor(self): """Toggles the :class:`Ui_Form` console between dark mode and light mode """ - if self.dark_color is True: + if self.darkColor 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 + self.lightDarkModeButton.setIcon(QtGui.QIcon(os.path.join(self.iconDir, "dark_mode.png"))) + self.darkColor = 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 + self.lightDarkModeButton.setIcon(QtGui.QIcon(os.path.join(self.iconDir, "light_mode.png"))) + self.darkColor = True
\ No newline at end of file diff --git a/src/frontEnd/TerminalUi.ui b/src/frontEnd/TerminalUi.ui new file mode 100644 index 00000000..9039984d --- /dev/null +++ b/src/frontEnd/TerminalUi.ui @@ -0,0 +1,163 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>TerminalUi</class> + <widget class="QWidget" name="TerminalUi"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>1244</width> + <height>644</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <widget class="QWidget" name="verticalLayoutWidget"> + <property name="geometry"> + <rect> + <x>10</x> + <y>10</y> + <width>1131</width> + <height>471</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="sizeConstraint"> + <enum>QLayout::SetDefaultConstraint</enum> + </property> + <property name="leftMargin"> + <number>15</number> + </property> + <property name="topMargin"> + <number>15</number> + </property> + <property name="rightMargin"> + <number>15</number> + </property> + <property name="bottomMargin"> + <number>15</number> + </property> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QProgressBar" name="progressBar"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>35</height> + </size> + </property> + <property name="styleSheet"> + <string notr="true">QProgressBar::chunk { + background-color: rgb(54,158,225); +}</string> + </property> + <property name="maximum"> + <number>0</number> + </property> + <property name="value"> + <number>-1</number> + </property> + <property name="format"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="redoSimulationButton"> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>35</height> + </size> + </property> + <property name="text"> + <string>Resimulate</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="cancelSimulationButton"> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>35</height> + </size> + </property> + <property name="text"> + <string>Cancel Simulation</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="lightDarkModeButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>35</width> + <height>35</height> + </size> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QTextEdit" name="simulationConsole"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>400</height> + </size> + </property> + <property name="styleSheet"> + <string notr="true">QTextEdit { + background-color: rgb(36, 31, 49); + color: white; +}</string> + </property> + <property name="html"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string> + </property> + <property name="textInteractionFlags"> + <set>Qt::NoTextInteraction</set> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/src/ngspiceSimulation/NgspiceWidget.py b/src/ngspiceSimulation/NgspiceWidget.py index 3e6882b5..e828493e 100644 --- a/src/ngspiceSimulation/NgspiceWidget.py +++ b/src/ngspiceSimulation/NgspiceWidget.py @@ -18,15 +18,15 @@ class NgspiceWidget(QtWidgets.QWidget): QtWidgets.QWidget.__init__(self) self.obj_appconfig = Appconfig() self.process = QtCore.QProcess(self) - self.terminal = QtWidgets.QWidget(self) + #self.terminal = QtWidgets.QWidget(self) self.projDir = self.obj_appconfig.current_project["ProjectName"] self.checkChangeInPlotFile = simulationEssentials['checkChangeInPlotFile'] self.enableButtons = simulationEssentials['enableButtons'] self.args = ['-b', '-r', command.replace(".cir.out", ".raw"), command] - self.terminalUi = TerminalUi.Ui_Form(self.process, self.args) - self.terminalUi.setupUi(self.terminal) + self.terminalUi = TerminalUi.TerminalUi(self.process, self.args) + #self.terminalUi.setupUi(self.terminal) self.layout = QtWidgets.QVBoxLayout(self) - self.layout.addWidget(self.terminal) + self.layout.addWidget(self.terminalUi) print("Argument to ngspice command : ", command) @@ -90,7 +90,7 @@ class NgspiceWidget(QtWidgets.QWidget): def writeSimulationStatus(self): """This function writes status of the simulation (Success or Failure) to the - :class:`TerminalUi.Ui_Form` console. + :class:`TerminalUi.TerminalUi` console. """ if self.readyToPrintSimulationStatus is False: return @@ -108,7 +108,7 @@ class NgspiceWidget(QtWidgets.QWidget): @QtCore.pyqtSlot() def readyReadAll(self): - """Outputs the ngspice process standard output and standard error to :class:`TerminalUi.Ui_Form` console + """Outputs the ngspice process standard output and standard error to :class:`TerminalUi.TerminalUi` console """ self.terminalUi.simulationConsole.insertPlainText( str(self.process.readAllStandardOutput().data(), encoding='utf-8') |