In wxPython, if I create a list of radio buttons and place the list initially, is it possible to change the contents in that list later?
For example, I have a panel that uses a boxSizer to place the widgets initially. One of those widgets is a list of radio buttons (I have also tried a normal radiobox). I would like to dynamically change the list based on variables from another class.
However, once the list is placed in the sizer, it's effectively "locked"; I can't just modify the list and have the changes appear. If I try re-adding the list to the sizer, it just gets put in the top left corner of the panel.
I'm sure I could hide the original list and manually place the new list in the same position but that feels like a kludge. I'm sure I'm making this harder than it is. I'm probably using the wrong widgets for this, much less the wrong approach, but I'm building this as a learning experience.
class Job(wiz.WizardPageSimple): """Character's job class.""" def __init__(self, parent, title, attribs): wiz.WizardPageSimple.__init__(self, parent) self.next = self.prev = None self.sizer = makePageTitle(self, title) self.charAttribs = attribs #---Create widgets self.Job_list = ["Aircraft Mechanic", "Vehicle Mechanic", "Electronics Specialist"] box1_title = wx.StaticBox( self, -1, "" ) box1 = wx.StaticBoxSizer( box1_title, wx.VERTICAL ) grid1 = wx.BoxSizer(wx.VERTICAL) for item in self.Job_list: radio = wx.RadioButton(self, -1, item) grid1.Add(radio) ##Debugging self.btn = wx.Button(self, -1, "click") self.Bind(wx.EVT_BUTTON, self.eligibleJob, self.btn) #---Place widgets self.sizer.Add(self.Job_intro) self.sizer.Add(self.btn) box1.Add(grid1) self.sizer.Add(box1) def eligibleJob(self, event): """Determine which Jobs a character is eligible for.""" if self.charAttribs.intelligence >= 12: skillList = ["Analyst", "Interrogator", "Fire Specialist", "Aircraft Pilot"] for skill in skillList: self.Job_list.append(skill) print self.Job_list ##Debugging #return self.Job_list