[wxPython-users] Binding mouse clicks to toolbar button

wormwood_3 wormwood_3 at yahoo.com
Tue Sep 25 10:35:55 PDT 2007


>> EVT_TOOL is, for all intents and purposes, the same as EVT_MENU.  So 
this enables a little trick that may not be readily apparent from Python 
(but is used often in C++) which is that if the menu items and their 
corresponding toolbar items have the same ID, then you can handle both 
with the same event binding.  They can also be enabled/disabled with the 
same EVT_UPDATE_UI binding too.
[...]

Great to know. I will implement this form from now on. Thanks!

>> BTW, no need to create a wx.Image if you are just going to convert it to 
a bitmap.  The wx.Bitmap constructor will do all of this itself if it 
needs to.  This will work just as well, and is a lot less to type:

    wx.Bitmap('resources/help-browser.png')


I had put that code in not really knowing how it worked. Short form is much better.


-Sam







More information about the wxpython-users mailing list