Oh, I should have mentioned that this child class uses
the same event type as the parent. I did that so that
you could make one handler that catches all network
events. The downside of that is that each handler
that DIDN'T want every event would need a:
Event.Skip()
if not isinstance(Event, DesiredEventClass):
return
in their event handler. If you didn't want one
handler capable of catching all types of events, then
you'd want to put a:
Type = wx.NewEventType()
in each child event definition as well as the parent.
Gre7g
···
--- Gre7g Luterman <hafeliel@yahoo.com> wrote:
class NetworkEvent(wx.PyCommandEvent):
Type = wx.NewEventType()
def __init__(self):
wx.PyCommandEvent.__init__(self, self.Type,
-1)
EVT_NETWORK_EVENT = \
wx.PyEventBinder(NetworkEvent.Type, 1)
and then subclass it for each individual event I
needed to deal with, such as:
____________________________________________________________________________________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games. http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
class NetworkEvent(wx.PyCommandEvent):
Type = wx.NewEventType()
def __init__(self):
wx.PyCommandEvent.__init__(self, self.Type,
-1)
EVT_NETWORK_EVENT = \
wx.PyEventBinder(NetworkEvent.Type, 1)
and then subclass it for each individual event I
needed to deal with, such as:
class ErrPcktEvent(NetworkEvent):
def __init__(self, Msg):
self.Msg = Msg
NetworkEvent.__init__(self, self.Type, -1)
EVT_ERR_PCKT_EVENT = \
wx.PyEventBinder(ErrPcktEvent.Type, 1)
Oh, I should have mentioned that this child class uses
the same event type as the parent. I did that so that
you could make one handler that catches all network
events. The downside of that is that each handler
that DIDN'T want every event would need a:
Event.Skip()
if not isinstance(Event, DesiredEventClass):
return
in their event handler. If you didn't want one
handler capable of catching all types of events, then
you'd want to put a:
Type = wx.NewEventType()
in each child event definition as well as the parent.
Gre7g
____________________________________________________________________________________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
---------------------------------------------------------------------
To unsubscribe, e-mail: For additional commands, e-mail:
Alright, I tried the above but my method that I registered to the
exception isn’t getting called.
wx.PostEvent(Net_Evt_Handler, evt) #Net_Evt_Handler is my network event
handler
Other than that, everything else is the same as above.
DM
P.S. Gre7g I think you made a typo in your first response because when
you inherit from NetworkEvent you pass 3 arguments to its constructor
but it only takes one.
Alright, I tried the above but my method that I
registered to theexception isn't getting called.
This is how I bind to the event
network.EVT_CONNACC(self, wx.ID_ANY, self.OnConnAcc)
Use Bind now. That's the new standard:
wx.GetApp().Bind(EVT_CONNACC, self.OnConnAcc)
and this is how I post the event
wx.PostEvent(Net_Evt_Handler, evt) #Net_Evt_Handler
is my network eventhandler
Don't create your own handler. Just rely on the fact
that your application and windows subclass
wxEvtHandler.
wx.PostEvent(wx.GetApp(), evt)
Other than that, everything else is the same as
above.
DM
P.S. Gre7g I think you made a typo in your first
response because whenyou inherit from NetworkEvent
you pass 3 arguments to its constructorbut it only
takes one.
Oops. Thanks for catching that.
Gre7g
____________________________________________________________________________________Ready for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.