user-interfaceloopswxpythonreturngui-toolkit

Why does a simple method trigger a main loop message and then block?


Here it was told me something I can't understand about wxPython and other GUI toolkits.

When I call GetLabel from a 'static text' control, there gets an event enqueued and GetLabel doesn't return until this event was processed by the main loop.

Why gets an event enqueued for such a simple task?

Why doesn't the method return immediately, but block til the message was processed?


Solution

  • I don't think GetLabel fires an event. The problem you were having in that other question is that you were using threads to try to manipulate the GUI and get information from it. Your thread is blocking the GUI's main thread. If you called GetLabel() from within your GUI code (such as within an event handler for a button), it would be immediate.