Specific request with code example (encapsulation) __init__ problems

Justin justin__devine at hotmail.com
Thu Aug 26 16:46:38 CEST 2004

On the advice of some members of this group I have decided to post a
very specific question / problem with a code example.  My problem is
that my wxWidgets are created in the __init__ function of a panel.
(This is the way wx demos showed, I am brand new so I copies what they
did)  my problem is now it appears that my widgets are completely
encapsulated within this __init__ class and I cannot get at them.  Here
is an example of me trying to change the labels on a radiobox (all the
code that doesn't matter has been taken out)  you can see it all if you
like.  If the indentation is hard to understand due to the posting
syntax please let me know.  And thanks for your help in advance.
The indentation quickly is 1 class "Gmainpanel"  two functions
"__init__()" and changelabel()

class Gmainpanel(wx.Panel):
__shared_state = {}
def __init__(self, parent):
self.__dict__ = self.__shared_state
wx.Panel.__init__(self, parent, -1)

#Make the Radiobox
label_pickle = open("labels.dat", "r")
labellist = cPickle.load(label_pickle)

sizer = wx.BoxSizer(wx.HORIZONTAL)

self.rb = wx.RadioBox(self,-1, "QuickSites", (10, 215), (425,
70),labellist , 5,wx.RA_SPECIFY_COLS)

self.Bind(wx.EVT_RADIOBOX, EvtRadioBox, self.rb)

self.rb.SetToolTip(wx.ToolTip("You can select a specific
service to search"))
sizer.Add(self.rb, 0, wx.ALL, 20)

def changelabel(self):
self.rb.SetLabel(1, "test change")

More information about the Python-list mailing list