summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/frontEnd/TerminalUi.py57
-rw-r--r--src/ngspiceSimulation/NgspiceWidget.py19
2 files changed, 39 insertions, 37 deletions
diff --git a/src/frontEnd/TerminalUi.py b/src/frontEnd/TerminalUi.py
index b5f7a836..4d6e6d23 100644
--- a/src/frontEnd/TerminalUi.py
+++ b/src/frontEnd/TerminalUi.py
@@ -3,8 +3,9 @@ import os
class Ui_Form(object):
- def __init__(self, qProcess):
+ def __init__(self, qProcess, args):
self.qProcess = qProcess
+ self.args = args
self.iconDir = "../../images"
# super().__init__()
def setupUi(self, Form):
@@ -21,21 +22,21 @@ class Ui_Form(object):
self.horizontalLayout.setContentsMargins(-1, -1, -1, 0)
self.horizontalLayout.setSpacing(6)
self.horizontalLayout.setObjectName("horizontalLayout")
- self.terminalUi = QtWidgets.QProgressBar(self.verticalLayoutWidget)
+ self.progressBar = 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"
+ 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.terminalUi.setMaximum(0)
- self.terminalUi.setProperty("value", -1)
- self.terminalUi.setFormat("")
- self.terminalUi.setObjectName("progressBar")
- self.horizontalLayout.addWidget(self.terminalUi)
+ 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")
@@ -93,9 +94,6 @@ class Ui_Form(object):
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>'
@@ -105,35 +103,34 @@ class Ui_Form(object):
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)
+ self.progressBar.setMaximum(100)
+ self.progressBar.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()
+
+ #To show progressBar completed
+ self.progressBar.setMaximum(100)
+ self.progressBar.setProperty("value", 100)
- def setNgspiceArgs(self, args):
- self.args = args
+ self.simulationConsole.append(cancelFormat.format("Simulation Cancelled!"))
+ self.simulationConsole.verticalScrollBar().setValue(
+ self.simulationConsole.verticalScrollBar().maximum()
+ )
def redoSimulation(self):
if (self.qProcess.state() == QtCore.QProcess.Running):
return
- self.showProgressRunning()
+
+ #To make the progressbar running
+ self.progressBar.setMaximum(0)
+ self.progressBar.setProperty("value", -1)
+
self.simulationConsole.setText("")
self.qProcess.start('ngspice', self.args)
diff --git a/src/ngspiceSimulation/NgspiceWidget.py b/src/ngspiceSimulation/NgspiceWidget.py
index 1e6aca6f..0c431470 100644
--- a/src/ngspiceSimulation/NgspiceWidget.py
+++ b/src/ngspiceSimulation/NgspiceWidget.py
@@ -22,7 +22,8 @@ class NgspiceWidget(QtWidgets.QWidget):
self.projDir = self.obj_appconfig.current_project["ProjectName"]
self.checkChangeInPlotFile = simulationEssentials['checkChangeInPlotFile']
self.enableButtons = simulationEssentials['enableButtons']
- self.terminalUi = TerminalUi.Ui_Form(self.process)
+ 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.layout = QtWidgets.QVBoxLayout(self)
self.layout.addWidget(self.terminal)
@@ -49,9 +50,7 @@ class NgspiceWidget(QtWidgets.QWidget):
else: # For Linux OS
# Creating argument for process
self.currTime = time.time()
- self.args = ['-b', '-r', command.replace(".cir.out", ".raw"), command]
self.process.setWorkingDirectory(self.projDir)
- self.terminalUi.setNgspiceArgs(self.args)
self.process.start('ngspice', self.args)
self.process.started.connect(lambda: self.enableButtons(state=False))
self.process.readyReadStandardOutput.connect(lambda: self.readyReadAll())
@@ -72,7 +71,9 @@ class NgspiceWidget(QtWidgets.QWidget):
self.checkChangeInPlotFile(self.currTime, exitStatus)
self.readyToPrintSimulationStatus = True
- self.terminalUi.showProgressCompleted()
+ #To stop progressbar from running after simulation is completed
+ self.terminalUi.progressBar.setMaximum(100)
+ self.terminalUi.progressBar.setProperty("value", 100)
self.writeSimulationStatus()
@@ -89,15 +90,19 @@ class NgspiceWidget(QtWidgets.QWidget):
else:
self.terminalUi.writeSimulationStatusToConsole(isSuccess=False)
- self.terminalUi.scrollConsoleToBottom()
+ self.terminalUi.simulationConsole.verticalScrollBar().setValue(
+ self.terminalUi.simulationConsole.verticalScrollBar().maximum()
+ )
self.readyToPrintSimulationStatus = False
@QtCore.pyqtSlot()
def readyReadAll(self):
- self.terminalUi.writeIntoConsole(
+ self.terminalUi.simulationConsole.insertPlainText(
str(self.process.readAllStandardOutput().data(), encoding='utf-8')
)
stderror = self.process.readAllStandardError()
if stderror.toUpper().contains(b"ERROR"):
self.errorFlag = True
- self.terminalUi.writeIntoConsole(str(stderror.data(), encoding='utf-8')) \ No newline at end of file
+ self.terminalUi.simulationConsole.insertPlainText(
+ str(stderror.data(), encoding='utf-8')
+ ) \ No newline at end of file