[wxPython-users] widget suggestion / question

Christopher Barker Chris.Barker at noaa.gov
Mon Dec 3 11:19:52 PST 2007


Mark Erbaugh wrote:
> Thanks for the example. I think it should work, but I was hoping to
> avoid using the widget's label. It's possible that you might want to
> change the label text (say for internationalization) without changing
> the underlying code.

right, the label isn't necessarily the best key. yous can use the Label, 
you can use the ID (which you can get by .getID(), after creating the 
object with the default).

Most importantly though -- this is Python! it's been said before in this 
thread, but it bears repeating: you can any attribute you want to any 
object, no problem at all. For instance, using the previous example, I 
might do:

            for label in rows:
                button = wx.Button(self, wx.ID_ANY, label)
                button.SetMinSize((30,30))
                button.NumberValue = int(label)
                self.Bind(wx.EVT_BUTTON, self.button_handler, button)
                button_sizer.Add(button)
  ...

    def button_handler(self, event):
        Value = event.GetEventObject().NumberValue
        .. Do something with Value....


-Chris





-- 
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