Dynamically generated control arrays: more elegant getters?

Alexandru Tabac ha scritto:

Is there a better way to yank the data from the controls without a double cycle of

sizerItemList=self.containerSizer.GetChildren()
for eachSizerItem in sizerItemList:
    controlSizerItems=eachSizerItem.GetSizer().GetChildren()
    for controlSizerItem in controlSizerItems:
        if isinstance(controlSizerItem.GetWindow(), wx.TextCtrl):
            #finally get values here.

You can use a list of controls. After the creation of a TextCtrl, you can add the control to the list in this way:

self.controls.append(TextControlJustCreated)

In the __init__ function of the parent you have to insert the declaration of self.controls:

self.controls = # an empty list

After that, retrieving the value is quite simple:

for control in self.controls:
  value = control.GetValue()

HTH!
Simone
Chiacchiera con i tuoi amici in tempo reale! http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com

Ah. Plain Python, but it should work a lot better. Thanks!

···

On Jan 4, 2008, at 9:29 AM, Simone wrote:

Alexandru Tabac ha scritto:

Is there a better way to yank the data from the controls without a double cycle of
sizerItemList=self.containerSizer.GetChildren()
for eachSizerItem in sizerItemList:
   controlSizerItems=eachSizerItem.GetSizer().GetChildren()
   for controlSizerItem in controlSizerItems:
       if isinstance(controlSizerItem.GetWindow(), wx.TextCtrl):
           #finally get values here.

You can use a list of controls. After the creation of a TextCtrl, you can add the control to the list in this way:

self.controls.append(TextControlJustCreated)

In the __init__ function of the parent you have to insert the declaration of self.controls:

self.controls = # an empty list

After that, retrieving the value is quite simple:

for control in self.controls:
  value = control.GetValue()

HTH!
Simone
Chiacchiera con i tuoi amici in tempo reale! Yahoo fa parte della famiglia di brand Yahoo.
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org