What other event properties are contained in the application object

To manage the main event loop more directly, you can modify it using some wx.App methods. For instance, you may want to start processing the next available event on your own schedule, rather than waiting for wxPython to begin processing. This feature is necessary if you are starting a long procedure, and don't want the GUI to appear to freeze. You won't need to use the methods in this section often, but it's occasionally important to have these capabilities.

Table 3.4 lists the wx.App methods you can use to modify the main loop.

Table 3.4 Event main loop methods of wx.App

Method Name

Method Description


Programmatically forces the next event in the event queue to be sent. Used by MainLoop(), for example, or in customized event loops.


Returns True if there are pending events in the wxPython application event queue.

Yield(onlyIfNeeded = False)

Allows pending wxWidgets events to be dispatched in the middle of a long process that might otherwise block the windowing system from displaying or updating. Returns True if there were pending events that were processed, False otherwise.

If True, the onlyifNeeded parameter forces the process to yield if there are actually pending events. If the argument is False, then it is an error to call Yield recursively.

There is also a global function wx.safeYield(), which prevents the user from inputting data during the yield (by temporarily disabling user-input widgets). This prevents the user from doing something that would violate the state needed by the yielding task.

Another method for managing events in a custom way is to create your own event types that match the specifics of your application's data and widgets. In the next section, we will discuss how to create your own custom events.

Was this article helpful?

0 0

Post a comment