19. Multithreading
Traditionally, applications have a single thread of execution and perform one operation at a time. For GUI programs this can sometimes be a problem—for example, if the user invokes a long-running operation, the user interface might freeze up while the operation is taking place. There are a few solutions that can be tried to eliminate this problem.
One simple solution, particularly useful in long-running loops, is to call QApplication.processEvents()
. This method gives the event loop the opportunity to handle any unprocessed events, such as paint events, as well as mouse and key press events.Another solution is to use zero-timeout ...
Get Rapid GUI Programming with Python and Qt: The Definitive Guide to PyQt Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.