[wxPython-users] binding to the frame or the specific instance?

Robin Dunn robin at alldunn.com
Fri Jul 21 19:01:11 PDT 2006


John Salerno wrote:
> Ok, confused again with this example. From my understanding,
> non-CommandEvent events must be bound to the instance itself, not to
> the frame. But when I do this:
> 
> self.timer.Bind(wx.EVT_TIMER, self.OnTimer)
> 
> instead of:
> 
> self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
> 
> it doesn't work. So why does binding to the frame work in this case
> and the other way doesn't work?

Because for every rule there is an exception.  ;-)  Timers don't deliver 
the events to themselves[*], but to the window that was passed to the 
wx.Timer constructor or the SetOwner method.


[*] Actually in a way they do if there is no owner set, but instead of 
processing the event normally they call the Notify method of a derived 
class.  This is done for backwards compatibility with how the timers 
used to work before they were taught how to send events to windows.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list