The main issue with multi-threaded GUI programming is the thread safty of the GUI itself. On most platforms the GUI is not thread safe and so any cross platform GUI Toolkit and applications written with it need to take that into account.
The solution is to only allow interaction with the GUI from a single thread, but this often severely limits what can be done in an application and makes it difficult to use additional threads at all.
Since wxPython already makes extensive use of event handlers, it is a logical extension to allow events to be sent to GUI objects from alternate threads. A function called wx.PostEvent allows you to do this. It accepts an event and an event handler (window) and instead of sending the event immediately in the current context like ProcessEvent does, it processes it later from the context of the GUI thread.
한마디로 파이썬의 threading 패키지와 wxPython의 wx.PostEvent를 적절히 이용하여 멀티쓰레드 GUI 프로그래밍을 한다.
[Threads example screenshot]




덧글