X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fe953afb43a163ad45fcd9513641f126570bab26..82805fe2805636891305796658219faa038677a4:/wxPython/src/msw/wx.py diff --git a/wxPython/src/msw/wx.py b/wxPython/src/msw/wx.py index ae2194e9f7..148ac8b3ee 100644 --- a/wxPython/src/msw/wx.py +++ b/wxPython/src/msw/wx.py @@ -1571,6 +1571,29 @@ def wxPyTypeCast(obj, typeStr): #---------------------------------------------------------------------------- +_wxCallAfterId = None + +def wxCallAfter(callable, *args, **kw): + """ + Call the specified function after the current and pending event + handlers have been completed. + """ + app = wxGetApp() + assert app, 'No wxApp created yet' + + global _wxCallAfterId + if _wxCallAfterId is None: + _wxCallAfterId = wxNewId() + app.Connect(-1, -1, _wxCallAfterId, + lambda event: apply(event.callable, event.args, event.kw) ) + evt = wxPyEvent() + evt.SetEventType(_wxCallAfterId) + evt.callable = callable + evt.args = args + evt.kw = kw + wxPostEvent(app, evt) + +#---------------------------------------------------------------------- class wxPyDeadObjectError(AttributeError): pass