X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/203c2f9a9acd71ae956b600d35ee46405a247215..2f1cd9053bf4fa0b04db5c38f6b7077f2ad95cfd:/wxPython/src/_extras.py diff --git a/wxPython/src/_extras.py b/wxPython/src/_extras.py index fd014225e5..5289d06a0e 100644 --- a/wxPython/src/_extras.py +++ b/wxPython/src/_extras.py @@ -654,6 +654,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