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

John Salerno johnjsal at gmail.com
Fri Jul 21 12:46:47 PDT 2006


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?

Thanks,
John



On 7/21/06, John Salerno <johnjsal at gmail.com> wrote:
> > ---------- Forwarded message ----------
> > From: Robin Dunn <robin at alldunn.com>
> > To: wxPython-users at lists.wxwidgets.org
> > Date: Thu, 20 Jul 2006 17:34:12 -0700
> > Subject: Re: [wxPython-users] binding to the frame or the specific instance?
> > John Salerno wrote:
> > > Can someone explain to me the difference between these two ways of
> > > binding a click event:
> > >
> > > self.Bind(wx.EVT_BUTTON, self.OnClick, self.button)
> > >
> > > and
> > >
> > > self.button.Bind(wx.EVT_BUTTON, self.OnClick)
> > >
> > > Both seem to work, so I assume in some cases it doesn't matter which
> > > you use. Did I just get lucky here, or can buttons be done either way?
> >
> > http://wiki.wxpython.org/index.cgi/self.Bind_vs._self.button.Bind
> >
> > Yes, I was in a *very* metaphoric mood today.  ;-)
> >
> > --
> > Robin Dunn
> > Software Craftsman
> > http://wxPython.org  Java give you jitters?  Relax with wxPython!
>
> Thanks very much, that was a big help! I read it in your book already,
> but somehow that helped to solidify it a little more. It seems to make
> more sense to me to always use self.widget.Bind instead of just
> self.Bind, but as you know, there are possible repercussions to this.
>




More information about the wxpython-users mailing list