+def wxCallAfter(callable, *args, **kw):
+ """
+ Call the specified function after the current and pending event
+ handlers have been completed. This is also good for making GUI
+ method calls from non-GUI threads.
+ """
+ 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)
+
+# an alias
+wxRunLater = wxCallAfter
+
+#----------------------------------------------------------------------
+
+class wxPyDeadObjectError(AttributeError):
+ pass