From 111e990dbfce47c53eba5cbe85fc1fbcbe5fe76d Mon Sep 17 00:00:00 2001 From: Pranav P Date: Thu, 25 May 2023 17:32:05 +0530 Subject: Now loads TerminalUi from ui file --- src/frontEnd/TerminalUi.py | 116 ++++++----------------- src/frontEnd/TerminalUi.ui | 163 +++++++++++++++++++++++++++++++++ src/ngspiceSimulation/NgspiceWidget.py | 12 +-- 3 files changed, 196 insertions(+), 95 deletions(-) create mode 100644 src/frontEnd/TerminalUi.ui (limited to 'src') 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", "\n" -"\n" -"

The quick brown fox jumped over the lazy dog

")) + #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 @@ + + + TerminalUi + + + + 0 + 0 + 1244 + 644 + + + + Form + + + + + 10 + 10 + 1131 + 471 + + + + + QLayout::SetDefaultConstraint + + + 15 + + + 15 + + + 15 + + + 15 + + + + + 6 + + + 0 + + + + + + 0 + 0 + + + + + 16777215 + 35 + + + + QProgressBar::chunk { + background-color: rgb(54,158,225); +} + + + 0 + + + -1 + + + + + + + + + + + 16777215 + 35 + + + + Resimulate + + + + + + + + 16777215 + 35 + + + + Cancel Simulation + + + + + + + + 0 + 0 + + + + + 35 + 35 + + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 400 + + + + QTextEdit { + background-color: rgb(36, 31, 49); + color: white; +} + + + <!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> + + + Qt::NoTextInteraction + + + + + + + + + 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') -- cgit