Threads and the User Interface
Windows has a fairly flexible threading interface when it comes to the windows and other parts of the user interface, but there are still a number of restrictions.
Almost any thread in the system can create a window, but only the
thread that created the window can process messages for it. In
addition, it’s generally not a good idea to call window
functions from threads other than the thread that created the window.
Using the PostMessage functions is fine, but be
careful using any function that either directly or indirectly causes
a message to be sent a window bypassing the message queue. As this is
a Win32 restriction rather than a Python one, the restriction applies
whether you use PythonWin, Tkinter, wxPython or some other GUI
framework on Win32.
Microsoft provide some excellent articles on threading considerations when using windows from the Win32 API, which you should review for further information.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access