From: Bo G. <bo...@sy...> - 2005-05-30 14:32:14
|
I am working with TestNotebook, and am trying to create pages and populate the pages in the pages using a persistent dictionary. One of the properties in one of the pages is a wxGrid. The grid creation happens in on_initialize for the page: class FileSpecsWin(model.PageBackground): def on_initialize(self, event): self.fileGrid = wx.grid.Grid(name='fileGrid', parent=self.panel, pos=wx.Point(21, 64), size=wx.Size(400, 390), style=0) self.fileGrid.SetRowLabelSize(40) self.fileGrid.SetColLabelSize(17) ...etc the method which adds the page and populates the grid looks like this: class TestNotebook(model.Background): ...other methods... def open_projfile(self): try: projectFileRef = shelve.open(self.projectFile) except IOError: result = dialog.alertDialog(self,'File %s could not be opened - try again' % (self.projectFile), 'Error') else: if projectFileRef.has_key('File1Window'): self.file1Win = model.childWindow(self.components.notebook, FileSpecsWin) self.components.notebook.AddPage(self.file1Win, 'File 1 Specs', True) (self.file1Win.components.textFilePath.text, self.file1Win.components.buttonImport.enabled, self.file1Win.components.buttonLoad.enabled) = projectFileRef['File1Window'] if projectFileRef.has_key('File1GridData'): grid_data = projectFileRef['File1GridData'] self.set_grid_data(grid_data, self.file1Win.fileGrid) But, the grid doesn't exist when this method attempts to populate it. I get an error like this: AttributeError: 'FileSpecsWin' object has no attribute 'fileGrid' I thought this might have to do with stacking method calls, so I tried wx.CallAfter(self.set_grid_data, grid_data, self.file1Win.fileGrid), but that didn't work. I could use some sage advice at this point. Thanks. Bo Green |