The following code will work with both Python 2.7 and Python 3. PyQt (via Qt) provides an straightforward interface to do exactly that. The solution is simple: get your work out of the GUI thread (and into another thread). Because your app is no longer communicating with the OS, on MacOS X if you click on your app you will see the spinning wheel of death. To your user the application will appear to be unresponsive (because it is). ![]() However, if you need to perform longer-running tasks, for example opening/writing a large file, downloading some data, or rendering some complex image, there are going to be problems. If what you're doing is simple, and returns control to the GUI loop quickly, this freeze will be imperceptible to the user. ![]() In practise this means that any time your PyQt application spends doing something in your code, window communication and GUI interaction are frozen. The thread which runs this event loop - commonly referred to as the GUI thread - also handles all window communication with the host operating system.īy default, any execution triggered by the event loop will also run synchronously within this thread. ![]() exec_() on your QApplication object and runs within the same thread as your Python code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |