Dinqmic GetValue on textCtrl

Hi all.
I create 10 textCtrl with this simple cycle.
ID=0
while ID<10:

    self.text = wx.TextCtrl(self, ID, "")
    sizer_9.Add(self.t15, 0, wx.ADJUST_MINSIZE, 0)
    ID=ID+1

How can i use the GetValue function for all separated textCtrl?
explain me: if i write “hello” on the first textCtrl and “world” in the second, i would have the two different GetValue to read “hello” and “world”

Thanks all!

Bye.

···


Sbaush

Sbaush wrote:

Hi all.
I create 10 textCtrl with this simple cycle.
ID=0
while ID<10:
        self.text = wx.TextCtrl(self, ID, "")
        sizer_9.Add(self.t15, 0, wx.ADJUST_MINSIZE, 0)
        ID=ID+1

How can i use the GetValue function for all separated textCtrl?
explain me: if i write "hello" on the first textCtrl and "world" in the second, i would have the two different GetValue to read "hello" and "world"

You can save references to all the controls in a list and use that to get to them later.

  ID=0
  self.text =
  while ID<10:
           text = wx.TextCtrl(self, ID, "")
          sizer_9.Add(text, 0, wx.ADJUST_MINSIZE, 0)
    self.text.append(text)
          ID=ID+1
  ...

  val = self.text[0].GetValue()

Or you can find the control later by using its ID.

  ID=0
  while ID<10:
           text = wx.TextCtrl(self, ID, "")
          sizer_9.Add(text, 0, wx.ADJUST_MINSIZE, 0)
          ID=ID+1
  ...
  
  textctrl = self.FindWindowById(0)
  val = textctrl.GetValue()

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!