I'm guessing that it isn't doable, but you'll have to wait for Robin to return to get an answer.
I can tell you from past experience that having your own virtual event queue and trying to keep the event behavior correct across all the platforms is a nightmare, which is why the old PythonCard event system was tossed out.
Depending on what you want in the event instances, you could go the PythonCard route and bind all events to a central dispatcher and then "decorate" the incoming wxPython events based on the event type. In PythonCard 0.8 this is pretty straightforward and doesn't involve much code for the binding and dispatch. I went ahead and made wrapper classes for every event so that I could group the wxPython event function and id. Here's a snippet of a KeyDownEvent class. These are not subclasses or mixins of the native wxPython events, they are simply helpers.
class Event :
"""
Superclass of all event classes.
"""
def decorate(self, aWxEvent, source):
aWxEvent.target = aWxEvent.eventObject = source
return aWxEvent
class KeyEvent(Event):
def decorate(self, aWxEvent, source):
aWxEvent = Event.decorate(self, aWxEvent, source)
# this is basically the same block as MouseEvent.decorate
# but it seems wrong to have KeyEvent be a subclass of MouseEvent
aWxEvent.position = tuple(aWxEvent.GetPosition())
aWxEvent.x = aWxEvent.GetX()
aWxEvent.y = aWxEvent.GetY()
aWxEvent.altDown = aWxEvent.AltDown()
aWxEvent.controlDown = aWxEvent.ControlDown()
aWxEvent.shiftDown = aWxEvent.ShiftDown()
aWxEvent.keyCode = aWxEvent.GetKeyCode()
return aWxEvent
class KeyDownEvent(KeyEvent):
name = 'keyDown'
binding = wx.EVT_KEY_DOWN
id = wx.wxEVT_KEY_DOWN
In the dispatcher there is a reverse lookup from the id, which is all the native wxPython event provides, to the event class, so that I can "decorate" the native event before calling the real event handler or just calling skip if there is no event handler.
ka
···
On Aug 18, 2004, at 12:10 PM, Paul McNett wrote:
Can I mix-in my own functionality to the event objects that get
passed to the callback functions?
For example:
self.Bind(wx.EVT_BUTTON, self.onButton)
def onButton(self, event):
# I'd like event to be the normally-passed wx event object
# which has a class of mine mixed-in with it.
I've already got my own wx.PyCommandEvent and wx.PyEvent
subclasses with my mixed-in class, and this works for sending
my own custom events, but I also want the wx-generated events
to include my mixin class.
I thought of just catching the wx event and re-raising it as a
custom event, but that would fork the event and user code no
longer has control over whether the original wx event is
Skipped or not...