[wxPython-users] Binding mouse clicks to toolbar button
Robin Dunn
robin at alldunn.com
Wed Sep 26 11:24:33 PDT 2007
Chris.Barker at noaa.gov wrote:
>> Instead of wx.EVT_LEFT_DOWN, try to do something like:
>>
>> self.Bind(wx.EVT_TOOL, self.OnCloseMe, id=exitbutton.GetId())
>
> Or even better (at least to my eye):
>
> exitbutton.Bind(wx.EVT_TOOL, self.OnCloseMe)
If exitbutton is a toolbar tool then it doesn't have a Bind method since
it isn't a wx.Evthandler, so you do need to bind to the frame. But Bind
will do the GetId() itself if it needs to, so you can do this to save a
few keystrokes:
self.Bind(wx.EVT_TOOL, self.OnCloseMe, exitbutton)
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list