title: wxpython - Creating Unique GUI Elements With a Loop
body: <p>I am attempting to create a GUI with a large amount of items where there are several sets of the same thing (six labels and six radioboxes).</p>
  
  <p>What I want to do (to save space and for a learning experience) is to create some sort of loop to place these elements on the panel I am using.</p>
  
  <p>Actually placing these should be easy, but the kicker is, I need them to all be unique in some way so I can individually change each label or get each value of each radiobox individually.</p>
  
  <p>Below is the code I have right now, where all the elements are individually created and placed.</p>
  
  <pre><code>sizerMain = wx.BoxSizer()
  ## For the main control area
  panelControl = wx.Panel(self,1,style = wx.MAXIMIZE)
  sizerControl = wx.GridBagSizer(hgap = 4,vgap = 4)
  
  # Add widgets
  ## Main content area
  lblTitle = wx.StaticText(panelControl,label = "Pick Scores")
  sizerControl.Add(lblTitle,pos = (0,0),
                   flag = wx.ALIGN_CENTER|wx.TOP|wx.LEFT|wx.BOTTOM,
                   border = 5)
  
  self.btnRoll = wx.Button(panelControl,label = "Roll!")
  sizerControl.Add(self.btnRoll,pos = (0,1),span = (1,5),
                   flag = wx.EXPAND|wx.LEFT|wx.RIGHT,border = 5)
  ### Radio boxes
  #### Radio button tuple
  rboxPick = ["Default","Strength","Dexterity","Constitution",
              "Intelligence","Wisdom","Charisma"]
  
  self.lblRoll1 = wx.StaticText(panelControl)
  sizerControl.Add(self.lblRoll1,pos = (1,0),flag = wx.ALIGN_CENTER)
  self.rboxRoll1 = wx.RadioBox(panelControl,label = "Roll One",choices = rboxPick)
  sizerControl.Add(self.rboxRoll1,pos = (1,1),span = (1,5),
                   flag = wx.EXPAND|wx.LEFT|wx.RIGHT,border = 2)
  
  self.lblRoll2 = wx.StaticText(panelControl)
  sizerControl.Add(self.lblRoll2,pos = (2,0),flag = wx.ALIGN_CENTER)
  self.rboxRoll2 = wx.RadioBox(panelControl,label = "Roll Two",choices = rboxPick)
  sizerControl.Add(self.rboxRoll2,pos = (2,1),span = (1,5),
                   flag = wx.EXPAND|wx.LEFT|wx.RIGHT,border = 2)
  
  self.lblRoll3 = wx.StaticText(panelControl)
  sizerControl.Add(self.lblRoll3,pos = (3,0),flag = wx.ALIGN_CENTER)
  self.rboxRoll3 = wx.RadioBox(panelControl,label = "Roll Three",choices = rboxPick)
  sizerControl.Add(self.rboxRoll3,pos = (3,1),span = (1,5),
                   flag = wx.EXPAND|wx.LEFT|wx.RIGHT,border = 2)
  
  self.lblRoll4 = wx.StaticText(panelControl)
  sizerControl.Add(self.lblRoll4,pos = (4,0),flag = wx.ALIGN_CENTER)
  self.rboxRoll4 = wx.RadioBox(panelControl,label = "Roll Four",choices = rboxPick)
  sizerControl.Add(self.rboxRoll4,pos = (4,1),span = (1,5),
                   flag = wx.EXPAND|wx.LEFT|wx.RIGHT,border = 2)
  
  self.lblRoll5 = wx.StaticText(panelControl)
  sizerControl.Add(self.lblRoll5,pos = (5,0),flag = wx.ALIGN_CENTER)
  self.rboxRoll5 = wx.RadioBox(panelControl,label = "Roll Five",choices = rboxPick)
  sizerControl.Add(self.rboxRoll5,pos = (5,1),span = (1,5),
                   flag = wx.EXPAND|wx.LEFT|wx.RIGHT,border = 2)
  
  self.lblRoll6 = wx.StaticText(panelControl)
  sizerControl.Add(self.lblRoll6,pos = (6,0),flag = wx.ALIGN_CENTER)
  self.rboxRoll6 = wx.RadioBox(panelControl,label = "Roll Six",choices = rboxPick)
  sizerControl.Add(self.rboxRoll6,pos = (6,1),span = (1,5),
                   flag = wx.EXPAND|wx.LEFT|wx.RIGHT,border = 2)
  </code></pre>
  
  <p>Also, it is late.. So if I am not making sense please let me know and I will be happy to re-explain..</p>