May 2019
Intermediate to advanced
542 pages
13h 37m
English
While timers allow us to defer actions to the event queue and can help to prevent awkward pauses in our programs, it's important to understand that functions connected to the timeout signal are still executed in—and will therefore block—the main execution thread.
For example, suppose that we have a long blocking method, as follows:
def long_blocking_callback(self): from time import sleep self.statusBar().showMessage('Beginning a long blocking function.') sleep(30) self.statusBar().showMessage('Ending a long blocking function.')
You might think that calling this method from a single shot timer will prevent it from locking up your application. Let's test that theory by adding this code to MainView.__init__():
qtc.QTimer.singleShot(1, ...
Read now
Unlock full access