0

I have a very similar problem with this post, but in Python.

I have a GUI with Pyqt5 as the main thread (e.g. gui.py) and a worker thread in a different python code (e.g. worker.py). The code in the worker.py can raise exceptions, such as FileNotFoundError. I need the main thread to catch these exceptions, stops the worker thread, and show the error message in a QMessageBox with an OK button. When the OK Button is pressed, the QMessageBox is closed and the app is restarted.

What I have tried so far:

  • Make a QMessagebox in worker.py as the error handling --> QMessagebox shows the error, but then the whole app is terminated. I assume because the main thread is a while True Loop and it is forced to stop
  • Make an Exception Hook using this tutorial --> A QMessagebox is shown without the error message and the whole app freezes.

I read this post, however I still don't understand how to put the exception of the worker thread in a bucket then connect it to the main thread, if the worker and main thread not in the same python file.

naomikim
  • 65
  • 5

0 Answers0