Nov-04-2019, 05:15 PM
Keep in mind that when running QThreads or even Python Threads you are dealing with the Python GIL (look it up if you are not familiar with it) but in a nutshell this simply means while you have Threads these threads are all run linearly such that only one operation (thread) is being executed at a time. So if you have 2 Sub-Threads and the Main Thread (QApplication) then if you launch anything within in any one of these 3 Threads that is a continuous process nothing else is going to be able to do anything until that continuous process finishes or you some how pass control back the the Event Handler Thread (QApplication)
So when designing Threads within Python you must keep this in mind, if your program seems to freeze this is because you have locked out (or blocked) the Event Handler from doing its job -- however all those events still stack up within the Event Queue such that once the Event Handler gets back control it will process every Event that was Queue up.
So in a secondary nutshell if you want your GUI (which must be in a Main Thread - QApplication) to be viable while you do things in other aspects of your program you need to create a Multiprocess and put the GUI in one process and everything else in the other process or create more than one Multiprocess and put everything within its own process
So when designing Threads within Python you must keep this in mind, if your program seems to freeze this is because you have locked out (or blocked) the Event Handler from doing its job -- however all those events still stack up within the Event Queue such that once the Event Handler gets back control it will process every Event that was Queue up.
So in a secondary nutshell if you want your GUI (which must be in a Main Thread - QApplication) to be viable while you do things in other aspects of your program you need to create a Multiprocess and put the GUI in one process and everything else in the other process or create more than one Multiprocess and put everything within its own process