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

John Salerno johnjsal at gmail.com
Sat Jul 22 09:49:14 PDT 2006


Thanks again! I'm starting to get it! :)

John


> ---------- Forwarded message ----------
> From: Robin Dunn <robin at alldunn.com>
> To: wxPython-users at lists.wxwidgets.org
> Date: Fri, 21 Jul 2006 19:01:11 -0700
> Subject: Re: [wxPython-users] binding to the frame or the specific instance?
> 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