Rows of static text

How do I create rows of static text in such a way that I can then later.

textrow[1].SetLabel("row one of text")

Hi Mike,

How do I create rows of static text in such a way that I can then later.

textrow[1].SetLabel("row one of text")

How about using a wxBoxSizer -- something like:

         self.labelPanel = wx.wxPanel(...) # Panel to hold all the labels.
         self.labelSizer = wx.wxBoxSizer(wx.wxVERTICAL)
         self.labels = # List of labels.

         self.addLabel("Value 1")
         self.addLabel("Value 2")
         self.addLabel("Value 3")
         ...etc

         self.labelPanel.SetAutoLayout(True)
         self.labelPanel.SetSizer(self.labelSizer)
         self.labelSizer.Fit(self.labelPanel)

         ...

         def addLabel(self, sizer, textrow, value):
                 """ Add a wxStaticText label to the window, adding it to the given list.
                 """
                 label = wx.wxStaticText(self.labelPanel, -1, value)
                 self.labelSizer.Add(label, 0, wx.wxALL | 5)
                 self.labels.append(label)

Then, you could use the following to change the value of one of your static text items:

         def setLabel(self, labelNum, newValue):
                 """ Set the text of label #labelNum to the given value.
                 """
                 label = self.labels[labelNum]

                 label.SetLabel(newValue)
                 label.SetSize(label.GetBestSize())

                 self.labelPanel.Layout()
                 self.Layout() # In case panel has grown or shrunk, and affects size of
                               # parent window.

Once you've set this up, it'd be trivial to change your labels with a single function call, eg, self.setLabel(0, "new value 1").

Warning -- I haven't tested this code at all; I just wrote it from memory. Hope you find it a useful starting point...

Cheers,

  - Erik.