diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/frontEnd/Application.py | 171 | ||||
-rwxr-xr-x | src/frontEnd/DockArea.py | 5 | ||||
-rw-r--r-- | src/frontEnd/icons/dark_mode.png | bin | 0 -> 951 bytes | |||
-rw-r--r-- | src/frontEnd/icons/light_mode.png | bin | 0 -> 989 bytes | |||
-rw-r--r-- | src/ngspiceSimulation/NgspiceWidget.py | 65 | ||||
-rw-r--r-- | src/progressBar/icons/dark_mode.png | bin | 0 -> 951 bytes | |||
-rw-r--r-- | src/progressBar/icons/light_mode.png | bin | 0 -> 989 bytes | |||
-rw-r--r-- | src/progressBar/progressBar.py | 145 | ||||
-rw-r--r-- | src/progressBar/progressBar.ui | 150 | ||||
-rw-r--r-- | src/progressBar/progressBarOld.py | 110 |
10 files changed, 568 insertions, 78 deletions
diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 7588b1a1..d584c714 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -83,6 +83,8 @@ class Application(QtWidgets.QMainWindow): self.systemTrayIcon.setIcon(QtGui.QIcon(init_path + 'images/logo.png')) self.systemTrayIcon.setVisible(True) + self.is_file_changed = False + def initToolBar(self): """ This function initializes Tool Bars. @@ -549,16 +551,99 @@ class Application(QtWidgets.QMainWindow): psutil.AccessDenied, psutil.ZombieProcess): pass return False + + def check_change_in_plotfile(self, currTime): + print("The function has executed") + try: + # if os.name == 'nt': + # proc = 'mintty' + # else: + # proc = 'xterm' + + # Edited by Sumanto Kar 25/08/2021 + if False and os.name != 'nt' and \ + self.checkIfProcessRunning('xterm') is False: + self.msg = QtWidgets.QErrorMessage() + self.msg.setModal(True) + self.msg.setWindowTitle("Warning Message") + self.msg.showMessage( + 'Simulation was interrupted/failed. ' + 'Please close all the Ngspice windows ' + 'and then rerun the simulation.' + ) + self.msg.exec_() + return + + st = os.stat(os.path.join(self.projDir, "plot_data_i.txt")) + is_ngspice_running = self.checkIfProcessRunning("ngspice") + print("Ngspice is running:", is_ngspice_running) + print(st.st_mtime, currTime) + if not is_ngspice_running: + if st.st_mtime >= currTime - 1: + self.is_file_changed = True + self.timer.stop() + + self.plot_simulation() + return + else: + self.timer.stop() + return + except Exception: + pass + + if self.is_file_changed is False: + self.timer.start() + + # Fail Safe ===> + self.count += 1 + if self.count >= 10: + self.timer.stop() + print( + "Ngspice taking too long for simulation. " + "Check netlist file (*.cir.out) " + "to change simulation parameters." + ) + + self.msg = QtWidgets.QErrorMessage() + self.msg.setModal(True) + self.msg.setWindowTitle("Warning Message") + self.msg.showMessage( + 'Ngspice taking too long for simulation. ' + 'Check netlist file (*.cir.out) ' + 'to change simulation parameters.' + ) + self.msg.exec_() + + return + + def enableButtons(self, state): + self.ngspice.setEnabled(state) + self.conversion.setEnabled(state) + self.closeproj.setEnabled(state) + self.wrkspce.setEnabled(state) + + def isSimulationSuccess(self): + return self.is_file_changed def open_ngspice(self): """This Function execute ngspice on current project.""" self.projDir = self.obj_appconfig.current_project["ProjectName"] + self.timer = QtCore.QTimer(self) + self.is_file_changed = False + + self.simulationEssentials = { + "timer": self.timer, + "enableButtons": self.enableButtons, + "isSimulationSuccess": self.isSimulationSuccess, + } if self.projDir is not None: + currTime = time.time() # Edited by Sumanto Kar 25/08/2021 + self.enableButtons(False) if self.obj_Mainview.obj_dockarea.ngspiceEditor( - self.projDir) is False: + self.projDir, self.simulationEssentials) is False: print( "Netlist file (*.cir.out) not found." ) @@ -572,71 +657,10 @@ class Application(QtWidgets.QMainWindow): self.msg.exec_() return - currTime = time.time() - count = 0 - while True: - try: - # if os.name == 'nt': - # proc = 'mintty' - # else: - # proc = 'xterm' - - # Edited by Sumanto Kar 25/08/2021 - if os.name != 'nt' and \ - self.checkIfProcessRunning('xterm') is False: - self.msg = QtWidgets.QErrorMessage() - self.msg.setModal(True) - self.msg.setWindowTitle("Warning Message") - self.msg.showMessage( - 'Simulation was interrupted/failed. ' - 'Please close all the Ngspice windows ' - 'and then rerun the simulation.' - ) - self.msg.exec_() - return - - st = os.stat(os.path.join(self.projDir, "plot_data_i.txt")) - if st.st_mtime >= currTime: - break - except Exception: - pass - time.sleep(1) - - # Fail Safe ===> - count += 1 - if count >= 10: - print( - "Ngspice taking too long for simulation. " - "Check netlist file (*.cir.out) " - "to change simulation parameters." - ) - - self.msg = QtWidgets.QErrorMessage() - self.msg.setModal(True) - self.msg.setWindowTitle("Warning Message") - self.msg.showMessage( - 'Ngspice taking too long for simulation. ' - 'Check netlist file (*.cir.out) ' - 'to change simulation parameters.' - ) - self.msg.exec_() - - return - - # Calling Python Plotting - try: - self.obj_Mainview.obj_dockarea.plottingEditor() - except Exception as e: - self.msg = QtWidgets.QErrorMessage() - self.msg.setModal(True) - self.msg.setWindowTitle("Error Message") - self.msg.showMessage( - 'Error while opening python plotting Editor.' - ' Please look at console for more details.' - ) - self.msg.exec_() - print("Exception Message:", str(e), traceback.format_exc()) - self.obj_appconfig.print_error('Exception Message : ' + str(e)) + self.count = 0 + self.timer.setInterval(1000) + self.timer.timeout.connect(lambda: self.check_change_in_plotfile(currTime)) + self.timer.start() else: self.msg = QtWidgets.QErrorMessage() @@ -648,6 +672,21 @@ class Application(QtWidgets.QMainWindow): ) self.msg.exec_() + def plot_simulation(self): + try: + self.obj_Mainview.obj_dockarea.plottingEditor() + except Exception as e: + self.msg = QtWidgets.QErrorMessage() + self.msg.setModal(True) + self.msg.setWindowTitle("Error Message") + self.msg.showMessage( + 'Error while opening python plotting Editor.' + ' Please look at console for more details.' + ) + self.msg.exec_() + print("Exception Message:", str(e), traceback.format_exc()) + self.obj_appconfig.print_error('Exception Message : ' + str(e)) + def open_subcircuit(self): """ This function opens 'subcircuit' option in left-tool-bar. diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index 461240b9..cf21199d 100755 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -117,9 +117,10 @@ class DockArea(QtWidgets.QMainWindow): ) count = count + 1 - def ngspiceEditor(self, projDir): + def ngspiceEditor(self, projDir, simulationEssentials): """ This function creates widget for Ngspice window.""" self.projDir = projDir + self.simulationEssentials = simulationEssentials self.projName = os.path.basename(self.projDir) self.ngspiceNetlist = os.path.join( self.projDir, self.projName + ".cir.out") @@ -133,7 +134,7 @@ class DockArea(QtWidgets.QMainWindow): self.ngspiceLayout = QtWidgets.QVBoxLayout() self.ngspiceLayout.addWidget( - NgspiceWidget(self.ngspiceNetlist, self.projDir) + NgspiceWidget(self.ngspiceNetlist, self.projDir, self.simulationEssentials) ) # Adding to main Layout diff --git a/src/frontEnd/icons/dark_mode.png b/src/frontEnd/icons/dark_mode.png Binary files differnew file mode 100644 index 00000000..a29b53f6 --- /dev/null +++ b/src/frontEnd/icons/dark_mode.png diff --git a/src/frontEnd/icons/light_mode.png b/src/frontEnd/icons/light_mode.png Binary files differnew file mode 100644 index 00000000..b40872c4 --- /dev/null +++ b/src/frontEnd/icons/light_mode.png diff --git a/src/ngspiceSimulation/NgspiceWidget.py b/src/ngspiceSimulation/NgspiceWidget.py index 8c63a22a..f7c88ba9 100644 --- a/src/ngspiceSimulation/NgspiceWidget.py +++ b/src/ngspiceSimulation/NgspiceWidget.py @@ -1,13 +1,15 @@ from PyQt5 import QtWidgets, QtCore from configuration.Appconfig import Appconfig from configparser import ConfigParser +from progressBar import progressBar import os +import time # This Class creates NgSpice Window class NgspiceWidget(QtWidgets.QWidget): - def __init__(self, command, projPath): + def __init__(self, command, projPath, simulationEssentials): """ - Creates constructor for NgspiceWidget class. - Checks whether OS is Linux or Windows and @@ -17,8 +19,13 @@ class NgspiceWidget(QtWidgets.QWidget): self.obj_appconfig = Appconfig() self.process = QtCore.QProcess(self) self.terminal = QtWidgets.QWidget(self) + self.simulationEssentials = simulationEssentials + self.qTimer = simulationEssentials['timer'] + self.progressBarUi = progressBar.Ui_Form(self.process, self.simulationEssentials) + self.progressBarUi.setupUi(self.terminal) self.layout = QtWidgets.QVBoxLayout(self) self.layout.addWidget(self.terminal) + self.errorFlag = False print("Argument to ngspice command : ", command) @@ -39,12 +46,15 @@ class NgspiceWidget(QtWidgets.QWidget): os.chdir(tempdir) else: # For Linux OS - self.command = "cd " + projPath + \ - ";ngspice -r " + command.replace(".cir.out", ".raw") + \ - " " + command + # self.command = "cd " + projPath + \ + # ";ngspice -r " + command.replace(".cir.out", ".raw") + \ + # " " + command # Creating argument for process - self.args = ['-hold', '-e', self.command] - self.process.start('xterm', self.args) + self.args = ['-b', '-r', command.replace(".cir.out", ".raw"), command] + self.process.setWorkingDirectory(projPath) + self.process.start('ngspice', self.args) + self.process.readyReadStandardOutput.connect(lambda: self.readyReadAll()) + self.process.finished.connect(self.finishSimulation) self.obj_appconfig.process_obj.append(self.process) print(self.obj_appconfig.proc_dict) ( @@ -52,7 +62,42 @@ class NgspiceWidget(QtWidgets.QWidget): [self.obj_appconfig.current_project['ProjectName']].append( self.process.pid()) ) - self.process = QtCore.QProcess(self) - self.command = "gaw " + command.replace(".cir.out", ".raw") - self.process.start('sh', ['-c', self.command]) - print(self.command) + self.gawProcess = QtCore.QProcess(self) + self.gawCommand = "gaw " + command.replace(".cir.out", ".raw") + self.gawProcess.start('sh', ['-c', self.gawCommand]) + print(self.gawCommand) + + def finishSimulation(self): + self.enableButtons = self.simulationEssentials['enableButtons'] + + self.enableButtons(True) + self.progressBarUi.showProgressCompleted() + + self.qTimer.timeout.connect(self.writeSimulationStatus) + + def writeSimulationStatus(self): + self.isSimulationSuccess = self.simulationEssentials['isSimulationSuccess'] + + if self.isSimulationSuccess(): + self.progressBarUi.writeSimulationStatusToConsole(isSuccess=True) + else: + self.progressBarUi.writeSimulationStatusToConsole(isSuccess=False) + + scrollLength = self.progressBarUi.simulationConsole.verticalScrollBar().maximum() + self.progressBarUi.simulationConsole.verticalScrollBar().setValue(scrollLength) + + @QtCore.pyqtSlot() + def readyReadAll(self): + self.progressBarUi.writeIntoConsole( + str(self.process.readAllStandardOutput().data(), encoding='utf-8') + ) + stderror = self.process.readAllStandardError() + if stderror.toUpper().contains(b"ERROR"): + self.errorFlag = True + self.progressBarUi.writeIntoConsole(str(stderror.data(), encoding='utf-8')) + + # def launchProgressBar(self): + # self.progressBar = QtWidgets.QWidget() + # self.progressBarUi = progressBar.Ui_Dialog() + # self.progressBarUi.setupUi(self.progressBar) + # self.progressBar.show() diff --git a/src/progressBar/icons/dark_mode.png b/src/progressBar/icons/dark_mode.png Binary files differnew file mode 100644 index 00000000..a29b53f6 --- /dev/null +++ b/src/progressBar/icons/dark_mode.png diff --git a/src/progressBar/icons/light_mode.png b/src/progressBar/icons/light_mode.png Binary files differnew file mode 100644 index 00000000..b40872c4 --- /dev/null +++ b/src/progressBar/icons/light_mode.png diff --git a/src/progressBar/progressBar.py b/src/progressBar/progressBar.py new file mode 100644 index 00000000..f0aa964f --- /dev/null +++ b/src/progressBar/progressBar.py @@ -0,0 +1,145 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'progressBar.ui' +# +# Created by: PyQt5 UI code generator 5.15.6 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets + + +class Ui_Form(object): + def __init__(self, qProcess, simulationEssentials): + self.qProcess = qProcess + self.qTimer = simulationEssentials['timer'] + self.enableButtons = simulationEssentials['enableButtons'] + self.isSimulationSuccess = simulationEssentials['isSimulationSuccess'] + # 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.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.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("icons/light_mode.png")) + self.light_dark_mode_button.clicked.connect(self.changeColor) + + self.cancel_simulation_button.clicked.connect(self.cancelSimulation) + + def writeIntoConsole(self, consoleLog): + self.simulationConsole.insertPlainText(consoleLog) + + def writeSimulationStatusToConsole(self, isSuccess): + failedFormat = '<span style="color:red;">{}</span>' + successFormat = '<span style="color:green;">{}</span>' + + if isSuccess: + self.simulationConsole.append(successFormat.format("Simulation Completed Successfully!")) + else: + self.simulationConsole.append(failedFormat.format("Simulation Failed!")) + + def showProgressCompleted(self): + self.progressBar.setMaximum(100) + self.progressBar.setProperty("value", 100) + + def cancelSimulation(self): + self.qTimer.stop() + self.qProcess.kill() + self.showProgressCompleted() + + 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("icons/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("icons/light_mode.png")) + self.dark_color = True + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + Form = QtWidgets.QWidget() + ui = Ui_Form() + ui.setupUi(Form) + Form.show() + sys.exit(app.exec_()) diff --git a/src/progressBar/progressBar.ui b/src/progressBar/progressBar.ui new file mode 100644 index 00000000..c85c0788 --- /dev/null +++ b/src/progressBar/progressBar.ui @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QWidget" name="Form"> + <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="cancel_simulation_button"> + <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="light_dark_mode_button"> + <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=" 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></string> + </property> + <property name="textInteractionFlags"> + <set>Qt::NoTextInteraction</set> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/src/progressBar/progressBarOld.py b/src/progressBar/progressBarOld.py new file mode 100644 index 00000000..451e5e18 --- /dev/null +++ b/src/progressBar/progressBarOld.py @@ -0,0 +1,110 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'progressBarNew.ui' +# +# Created by: PyQt5 UI code generator 5.15.6 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets + + +class Ui_Simulation(object): + def setupUi(self, Simulation): + Simulation.setObjectName("Simulation") + Simulation.resize(1250, 645) + self.horizontalLayout_2 = QtWidgets.QHBoxLayout(Simulation) + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.verticalLayout = QtWidgets.QVBoxLayout() + self.verticalLayout.setObjectName("verticalLayout") + self.progressBar = QtWidgets.QProgressBar(Simulation) + self.progressBar.setStyleSheet("") + self.progressBar.setMaximum(0) + self.progressBar.setProperty("value", -1) + self.progressBar.setFormat("") + self.progressBar.setObjectName("progressBar") + self.verticalLayout.addWidget(self.progressBar) + self.simulationConsole = QtWidgets.QTextEdit(Simulation) + 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.horizontalLayout_2.addLayout(self.verticalLayout) + self.verticalLayout_2 = QtWidgets.QVBoxLayout() + self.verticalLayout_2.setObjectName("verticalLayout_2") + spacerItem = QtWidgets.QSpacerItem(150, 30, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) + self.verticalLayout_2.addItem(spacerItem) + self.pushButton = QtWidgets.QPushButton(Simulation) + self.pushButton.setObjectName("pushButton") + self.verticalLayout_2.addWidget(self.pushButton) + self.pushButton_2 = QtWidgets.QPushButton(Simulation) + self.pushButton_2.setObjectName("pushButton_2") + self.verticalLayout_2.addWidget(self.pushButton_2) + self.pushButton_3 = QtWidgets.QPushButton(Simulation) + self.pushButton_3.setObjectName("pushButton_3") + self.verticalLayout_2.addWidget(self.pushButton_3) + self.pushButton_4 = QtWidgets.QPushButton(Simulation) + self.pushButton_4.setObjectName("pushButton_4") + self.verticalLayout_2.addWidget(self.pushButton_4) + self.pushButton_5 = QtWidgets.QPushButton(Simulation) + self.pushButton_5.setObjectName("pushButton_5") + self.verticalLayout_2.addWidget(self.pushButton_5) + spacerItem1 = QtWidgets.QSpacerItem(20, 400, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) + self.verticalLayout_2.addItem(spacerItem1) + self.horizontalLayout_2.addLayout(self.verticalLayout_2) + + self.retranslateUi(Simulation) + QtCore.QMetaObject.connectSlotsByName(Simulation) + + self.dark_color = True + + def retranslateUi(self, Simulation): + _translate = QtCore.QCoreApplication.translate + Simulation.setWindowTitle(_translate("Simulation", "Simulation")) + self.simulationConsole.setHtml(_translate("Simulation", "<!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.pushButton.setText(_translate("Simulation", "Cancel Simulation")) + self.pushButton_2.setText(_translate("Simulation", "Show Schematic")) + self.pushButton_3.setText(_translate("Simulation", "Plot_data_i.txt")) + self.pushButton_4.setText(_translate("Simulation", "Plot_data_v.txt")) + self.pushButton_5.setText(_translate("Simulation", "Switch Colour")) + + self.pushButton_5.clicked.connect(self.changeColor) + + def writeIntoConsole(self, consoleLog): + self.simulationConsole.insertPlainText(consoleLog) + + def showProgressCompleted(self): + self.progressBar.setMaximum(100) + self.progressBar.setProperty("value", 100) + + def changeColor(self): + if self.dark_color is True: + self.simulationConsole.setStyleSheet("QTextEdit {\n" + " background-color: white;\n" + " color: black;\n" + "}") + self.dark_color = False + else: + self.simulationConsole.setStyleSheet("QTextEdit {\n" + " background-color: rgb(36, 31, 49);\n" + " color: white;\n" + "}") + self.dark_color = True + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + Simulation = QtWidgets.QWidget() + ui = Ui_Simulation() + ui.setupUi(Simulation) + Simulation.show() + sys.exit(app.exec_()) |