I have a multithreading script in python with a Pyqt5 GUI as the main thread. I need to make a QMessageBox when an error arise in the worker thread with an ok button, which if pressed the QMessagebox closes, but the GUI keeps running. However my message box always freezes and the entire app would be then terminated.
Here is what i have done so far:
def run(self):
prog = Progress()
lastProgress = prog.progress
bucket = Queue()
thread = threading.Thread(target=main_beta.startScript, args=[prog, bucket])
thread.start()
while True:
if bucket.empty():
pass
else:
bucket.get(block=False, timeout=None)
self.errorHandling("error")
#do something forward
def errorHandling(self, errorMessage):
message = str(errorMessage)
app = QApplication(sys.argv)
msg = QMessageBox()
msg.setIcon(QMessageBox.Critical)
msg.setText(message)
msg.setWindowTitle("Critical!")
msg.setStandardButtons(QMessageBox.Ok)
returnValue = msg.exec_()
if returnValue == QMessageBox.Ok:
sys.exit(app.exec_())