Can someone explain to me why the first version of this method works, but the second one doesn't? All I've changed (I think) is how the information is nested. The error I'm getting is that the call to xrc.XRCCTRL is not working in the second example. Instead of getting the appropriate widget, it's returning None. Is this a result of the nesting, or the for loops perhaps?
Thanks. def OnSaveRecord(self, event): textfield_values = [] for tab in self.notebook.GetCurrentPage().GetChildren(): for table in self.get_textfield_ids(): table_values = [] for textfield_id in table: table_values.append(xrc.XRCCTRL(tab, textfield_id).GetValue()) textfield_values.append(table_values) self.save_to_database(textfield_values) def get_textfield_ids(self): return (('firstName', 'middleName', 'lastName', 'birthMonth', 'birthDay', 'birthYear', 'country', 'state', 'city'), ('jobTitle', 'salary', 'labBuilding', 'labRoom', 'labPhone'), ('localAddress', 'foreignAddress', 'emailAddress', 'homePhone', 'foreignPhone', 'cellPhone'), ('university1', 'yearStart1', 'yearEnd1', 'degree1', 'university2', 'yearStart2', 'yearEnd2', 'degree2', 'university3', 'yearStart3', 'yearEnd3', 'degree3', 'university4', 'yearStart4', 'yearEnd4', 'degree4'), ('notes')) ----------------------------------------- def OnSaveRecord(self, event): textfield_values = [] for tab in self.notebook.GetCurrentPage().GetChildren(): for textfield_id in self.get_textfield_ids(): textfield_values.append(xrc.XRCCTRL(tab, textfield_id).GetValue()) self.save_to_database(textfield_values) def get_textfield_ids(self): return ('firstName', 'middleName', 'lastName', 'birthMonth', 'birthDay', 'birthYear', 'country', 'state', 'city', 'jobTitle', 'salary', 'labBuilding', 'labRoom', 'labPhone', 'localAddress', 'foreignAddress', 'emailAddress', 'homePhone', 'foreignPhone', 'cellPhone', 'university1', 'yearStart1', 'yearEnd1', 'degree1', 'university2', 'yearStart2', 'yearEnd2', 'degree2', 'university3', 'yearStart3', 'yearEnd3', 'degree3', 'university4', 'yearStart4', 'yearEnd4', 'degree4', 'notes') Traceback (most recent call last): File "C:\Python25\myscripts\labdb\dbapp.py", line 91, in OnSaveRecord table_values.append(xrc.XRCCTRL(tab, textfield_id).GetValue()) AttributeError: 'NoneType' object has no attribute 'GetValue' -- http://mail.python.org/mailman/listinfo/python-list