Actually CallAfter gets called with these params
wx.CallAfter( self.SetItemCount, 42)
SetItemCount is a method of ListCtrl, 42 ist returned by my code.
This code worked under Python 3.5.x and wx Phoenix. It does not under Python 3.6.0 and the latest Phoenix.
The problem seems to lie here (have marked the relevant lines w/ # <===):
def _PyEvent_Clone(self):
"""
Make a new instance of the event that is a copy of self.
Through the magic of Python this implementation should work for
this and all derived classes.
"""
# Create a new instance
import copy
clone = copy.copy(self) # <===
# and then invoke the C++ copy constructor to copy the C++ bits too.
wx.PyEvent.__init__(clone, self)
return clone
PyEvent.Clone = _PyEvent_Clone
This function is called when PostEvent ist called, which seems to clone PyEvents.
What is self? It's a wx.PyEvent:
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.
:param PyObject callableObj: the callable object
:param args: arguments to be passed to the callable object
:param kw: keywords to be passed to the callable object
.. seealso::
:ref:`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) # <===
Paul
···
On 13/01/17 17:43, Michael Salin wrote:
Don't know what is UsrEventLog and what type self is.