Iterate on wx.TextCtrl of a frame

Giuseppe,

<div class="moz-text-flowed" style="font-family: -moz-fixed">Hi,
I iterate on some wx.TextCtrl in a frame to control if
some of this are empty.
I make this that work fine...

def OnSave(self,event):

        if self.OnFieldsControl()==0:
            return

def OnFieldsControl(self):

        dict_obj = {self.txProductName: 'Product',
                    self.txSupplierCode: 'Supplier Code',
                    self.cbSupplier: 'Company Name',
                    self.cbCategory: 'Category',
                    self.txDescription: 'Description',
                    self.txReorderLevel: 'Reorder level',
                    self.txQuantityPerUnit: 'Quantity per unit'}

        for k, v in dict_obj.items():
            if len(k.GetValue())==0:
                message="Attention!\nField %s is requested!"%(v)
                wx.MessageBox(message,data.AppTitle, wx.OK|wx.ICON_INFORMATION)
                k.SetFocus()
                return 0

There is another way to do this?

Ciao
Giuseppe

</div>

I'm not sure I completely follow, but I can take a shot at this. I'm pretty sure you can use your widget's parent's method, GetChildren() to get all the children. This may be easier to use than creating a custom dict, especially if you add more widgets to your app, but forget to add them to your dict.

You might also be able to use validators to tell if the user has added text and save as you go. I'm sure others on this list will have more interesting ideas though.

···

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org