From: Kevin A. <al...@se...> - 2004-09-14 18:04:17
|
There didn't seem to be any major objections, so I went ahead and checked in the Notebook component, the necessary changes to the framework, and a testNotebook sample. The changes should show up on anonymous cvs later this afternoon. See my other comments below. On Sep 14, 2004, at 5:43 AM, Alex Tweedly wrote: > At 16:41 13/09/2004 -0700, Kevin Altis wrote: >> The notebook component wouldn't have an attribute list for all the >> pages, instead you would add those manually by calling addPage, most >> likely in your on_initialize method. I made a pageWindow function >> that is almost identical to the childWindow function so that adding a >> page looks something like this: >> >> page = model.pageWindow(self.components.notebook, minimal.Minimal) >> self.components.notebook.AddPage(page, 'minimal', True) > > Any strong reason for not using an attribute list within the notebook > component ? > The fact that I have say 5 pages in the notebook feels like something > I should be dealing with in the resource Editor if possible. I agree, it seems natural to want to be able to provide a list of key, value pairs of the page name for the tab/key and the class as the value. It would be possible to parse the value such as minimal.Minimal and do the appropriate dynamic imports when the Notebook component is loaded. That could be a bit error-prone, but we can do some experiments and see how well it works. >> Since I didn't hide the wxPython methods behind a list interface, >> accessing a elements of the child pages look like: >> >> print self.components.notebook.GetPage(0).components.field1.text > > Would have been nice to be able to "name" the pages, and then > reference something like > print self.components.notebook.AboutPage.components.field1.text Again, this is an additional set of attribute hooks we'll have to try. When pages are added, it would be possible to do something like this in the Notebook component in small wrappers for AddPage and InsertPage: win = childWindow(...) name = pageText.replace(' ') self.AddPage(win, pageText, True) setattr(self, name, win) Rather than just removing spaces, the text would need to be completely sanitized so it only contains Alphanumerics and starts with a letter. The biggest problem would be name collision with an existing method or another page. So, we would need to decide whether to use a prefix to help protect against collision as well as provide some other means of auto-renaming... DeletePage would remove the attribute. >> So, will people be happy with this kind of solution? Any alternative >> suggestions? If I check this into cvs does anyone have a app or >> dialog they've been wanting to do that needs a wx.Notebook so we >> would have a decent test case to flesh out other issues? > > I've always wanted the code editor to use tabbed pages instead of > covering my screen with windows - but there's probably too big a > learning curve to try that. And in any case, it's an example where > each tab is identical - so probably not the most demanding test case. Excellent, I've been wanting to do that as well. It will require a refactor of the codeEditor to deal with multiple documents, but that will be a good change, because then it should be simpler to add an editor window to the resourceEditor as well. Maybe we can work on that together. > There'd be something ironic about adding tabbed browsing to the > simpleIEBrowser sample :-) :) > I would convert one of my Rev scripts that uses tabbed pages for > configuration settings and on-line help, just to compare - but again I > don't think that's a very demanding usage. > > -- Alex. The widgets sample could be refactored so each tab contains a different set of controls. ka |