From: Alex T. <al...@tw...> - 2004-09-14 12:38:54
|
At 16:41 13/09/2004 -0700, Kevin Altis wrote: >I sat down after the earlier posts about Notebook and did some >experiments. I created a Notebook component and made a simple sample that >uses the Notebook component and then manually adds a Panel with a TextCtrl >to the notebook. That worked fine and the resourceEditor worked with the >Notebook component too on the first try, though of course there weren't >any page attributes to complicate matters. Then I started trying to add >existing backgrounds as pages in the on_initialize method. You can't add a >wx.Frame as a notebook page and PythonCard backgrounds subclass wx.Frame >so that didn't work. > >I was able to get it to work by making a PageBackground class that is >almost identical to Background except that instead of a wx.Frame it >subclasses wx.Panel. Of course, many of the features of a Background don't >make any sense for a notebook page, so I commented out the menubar, >statusBar, and all of the events except idle. I had to make some further >tweaks to the event binding and dispatch to correctly deal with the >notebook pages without breaking events in Background and CustomDialogs, >but it all seems to be working now. I made a sample that uses the minimal >and widgets backgrounds without any changes except that instead of >model.Background, the Minimal and WidgetsTest background subclass >model.PageBackground. > >Since this was a fairly quick "hack" I hesitate to check it into cvs >without some discussion on the subject. > >If we went with a solution like this I would probably modify the >resourceEditor to support a new PageBackground template type. A >PageBackground is basically going to be like a Background, but there won't >be any menus, statusBar, etc., otherwise the .rsrc.py files will be almost >identical to keep things simple. You would edit each page of the notebook >separately just like you do different backgrounds today. If and when the >resourceEditor is changed to allow editing of multiple windows at once >that would be a little less clunky. >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. >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 >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. 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. |