Tkinter: Calling a multithreaded instance Tkinter: Calling a multithreaded instance tkinter tkinter

Tkinter: Calling a multithreaded instance


Not a specific answer, but your question is very broad.

Some points to keep in mind:

  • Tk is not thread-safe. That is, you should only invoke Tk calls from the main thread. It is OK to let other threads do non-gui work.
  • In CPython, only one thread at a time can be executing Python bytecode, due to the Global Interpreter Lock ("GIL"). So your non-gui thread could make the GUI unresponsive.

If you are only running one test at a time, and if you can divide that test into small pieces, you could use a timeout (also called alarm handler). This handler does a little bit of work, saves its state, updates the progress dialog and then exits, waiting to be invoked again.

If the test runs a long time and you want the GUI to remain responsive, I would suggest using multiprocessing instead of threading. Start your test in a different process, and use things like Queues and Semaphores et cetera to communicate between the GUI and non-qui processes.