widget suggestion / question

Chris Barker wrote:

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

Right. One can even go a step further, wxWidget are *Python object*.

A derived wx.Button class

class MyButton(wx.Button):

     def __init__(self, parent, id, label='', pos=wx.DefaultPosition, \
                  size=wx.DefaultSize, style=0, anyvalue=None):
         wx.Button.__init__(self, parent, id, label, pos, size, style=0)
         #p prefix for private, my preferred way
         self.pAnyValue = anyvalue

     def GetAnyValue(self):
         return self.pAnyValue

     def SetAnyValue(self, value):
         self.pAnyValue = value

     AnyValue = property(GetAnyValue, SetAnyValue)

Later, somewhere in the code:

         self.but1 = MyButton(self, wx.NewId(), 'button', anyvalue='asdf')
         print self.but1.AnyValue #print asdf
         self.but1.AnyValue = range(5)
         print self.but1.AnyValue #print [0, 1, 2, 3, 4]

Jean-Michel Fauth, Switzerland