When I execute a function with wx.CallAfter, inside it a variable is set. I want to be able to get the value of that variable on the next line, however CallAfter seems to execute the function a LOT later on. I think it pushes it in some queue that gets processed later or something... Is there a way to get that queue to be processed immediately?
This is the code of wx.CallAfter:
def CallAfter(callableObj, *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. Any extra positional or
keyword args are passed on to the callable when it is called.
:see: `wx.CallLater`
"""
assert callable(callableObj), "callableObj is not callable"
app = wx.GetApp()
assert app is not None, 'No wx.App created yet'
if not hasattr(app, "_CallAfterId"):
app._CallAfterId = wx.NewEventType()
app.Connect(-1, -1, app._CallAfterId,
lambda event: event.callable(*event.args, **event.kw) )
evt = wx.PyEvent()
evt.SetEventType(app._CallAfterId)
evt.callable = callableObj
evt.args = args
evt.kw = kw
wx.PostEvent(app, evt)
My assumption is that wx.PostEvent puts 'evt' in some internal container in 'app' and at some point that container is iterated and all elements have their 'callable' executed or something? So basically I need to cause this to happen immediately, but I can't find anything that looks like 'wx.ForceEventProcessing()' or 'wx.FlushEventsQueue'
I tried calling self.Update() in the panel where the methods are defined, but that just blocked the application and it stopped responding.