diff options
Diffstat (limited to 'src/progressBar')
-rw-r--r-- | src/progressBar/progressBar.py | 21 | ||||
-rw-r--r-- | src/progressBar/progressBar.ui | 150 | ||||
-rw-r--r-- | src/progressBar/progressBarOld.py | 110 |
3 files changed, 16 insertions, 265 deletions
diff --git a/src/progressBar/progressBar.py b/src/progressBar/progressBar.py index f0aa964f..24edb865 100644 --- a/src/progressBar/progressBar.py +++ b/src/progressBar/progressBar.py @@ -9,6 +9,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets +import os class Ui_Form(object): @@ -17,6 +18,7 @@ class Ui_Form(object): self.qTimer = simulationEssentials['timer'] self.enableButtons = simulationEssentials['enableButtons'] self.isSimulationSuccess = simulationEssentials['isSimulationSuccess'] + self.iconDir = "../progressBar/icons" # super().__init__() def setupUi(self, Form): Form.setObjectName("Form") @@ -93,7 +95,7 @@ class Ui_Form(object): self.simulationConsole.setText("") self.dark_color = True - self.light_dark_mode_button.setIcon(QtGui.QIcon("icons/light_mode.png")) + 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) @@ -102,22 +104,31 @@ class Ui_Form(object): self.simulationConsole.insertPlainText(consoleLog) def writeSimulationStatusToConsole(self, isSuccess): - failedFormat = '<span style="color:red;">{}</span>' - successFormat = '<span style="color:green;">{}</span>' + failedFormat = '<span style="color:#ff3333;">{}</span>' + successFormat = '<span style="color:#00ff00;">{}</span>' 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 showProgressCompleted(self): self.progressBar.setMaximum(100) self.progressBar.setProperty("value", 100) def cancelSimulation(self): + if not self.qTimer.isActive(): + return + cancelFormat = '<span style="color:#3385ff;">{}</span>' self.qTimer.stop() self.qProcess.kill() self.showProgressCompleted() + self.simulationConsole.append(cancelFormat.format("Simulation Cancelled!")) + self.scrollConsoleToBottom() def changeColor(self): if self.dark_color is True: @@ -125,14 +136,14 @@ class Ui_Form(object): " background-color: white;\n" " color: black;\n" "}") - self.light_dark_mode_button.setIcon(QtGui.QIcon("icons/dark_mode.png")) + 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("icons/light_mode.png")) + self.light_dark_mode_button.setIcon(QtGui.QIcon(os.path.join(self.iconDir, "light_mode.png"))) self.dark_color = True if __name__ == "__main__": diff --git a/src/progressBar/progressBar.ui b/src/progressBar/progressBar.ui deleted file mode 100644 index c85c0788..00000000 --- a/src/progressBar/progressBar.ui +++ /dev/null @@ -1,150 +0,0 @@ -<?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 deleted file mode 100644 index 451e5e18..00000000 --- a/src/progressBar/progressBarOld.py +++ /dev/null @@ -1,110 +0,0 @@ -# -*- 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_()) |