[wxPython-users] Adding "Standard" Buttons

Christopher Barker Chris.Barker at noaa.gov
Wed Feb 13 11:52:04 PST 2008


Mark Erbaugh wrote:
> I'd like to create some buttons with custom id's so I could add them to
> all the appropriate screens with wx.Button(parent, id=MY_NEW_ID) The
> text and bitmap on the button would be consistent across all frames.

Why  use the ID mechanism? That's there as kind of a hack to get 
platform-dependent behavior. What's wrong with:

class MySpecialButton(wx.Button): (or maybe the GenButton in wx.lib)
  ....

then

MySpecialButton(parent)


etc, etc....

This is, indeed, exactly what subclassing is for!

-CHB


-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov




More information about the wxpython-users mailing list