From: <bra...@om...> - 2005-05-31 22:51:54
|
Bo Green wrote on 05/30/2005 09:32:27 AM: > I could use some sage advice at this point. I'm afraid the sages may all be on sabbatical right now, but hopefully one will show up soon. I wish I was knowledgeable enough to help, but I didn't even realize you could add non-PythonCard components to a Background or a PageBackground, at least not without mucking about with the event model. Adding a wx.grid component is a pretty nifty thing to do; I had been wishing that PythonCard had a grid component. Anway, despite my lack of sagely knowledge, here are a few ideas: Has this grid component ever worked for you in a normal Background, outside the context of a notebook page? I noticed that you're creating the grid as self.fileGrid rather than self.components.fileGrid. Maybe it's worth a try to put it in self.components. You could also sprinkle in a few print statements to see if the on_initialize is happening when you think it's happening. Bo Green wrote on 05/30/2005 09:32:27 AM: > > 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 > > > > ------------------------------------------------------- > This SF.Net email is sponsored by Yahoo. > Introducing Yahoo! Search Developer Network - Create apps using Yahoo! > Search APIs Find out how you can build Yahoo! directly into your own > Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users |