Reputation: 305
I tried implementing the suggestion from subprocess Popen blocking PyQt GUI but it appears that the onFinished function is never getting invoked.
class MyApp(QtWidgets.QMainWindow, Ui_MainWindow):
[...]
def Run_PnL_Script(self):
self.Run_PnL.setEnabled(False)
self.Run_PnL.setStyleSheet("background-color: #D3D3D3; color: #FFFFFF")
self.PnL_Status.setText("Running...")
process = QtCore.QProcess(self)
process.finished.connect(self.onFinished)
process.startDetached("cmd.exe", ["/c", "K:\Market Risk\Risk App\Batches\RTest.bat"])
def onFinished(self, exitCode, exitStatus):
self.PnL_Status.setText("Complete.")
self.Run_PnL.setEnabled(True)
self.Run_PnL.setStyleSheet("background-color: #4582EC; color: #FFFFFF")
[...]
Thanks in advance for the help.
Upvotes: 1
Views: 231
Reputation: 244282
You have 2 errors:
RTest.bat
:: Another commands
EXIT
startDetached()
since this is a static method that creates an internal QProcess different from the "process" variable, you must use the start()
method.# ...
process = QtCore.QProcess(self)
process.finished.connect(self.onFinished)
process.start("cmd.exe", ["/c", "K:\Market Risk\Risk App\Batches\RTest.bat"])
Upvotes: 1