From: Kevin A. <al...@se...> - 2004-09-13 23:41:35
|
From an earlier message: "It is probably time for a separate discussion thread on the issues and possible solutions such as treating each page as a type of child window where only the components of the child window resource are used. I'm just brainstorming here. You would end up with a separate source and resource file for each tab/page. I guess the references to each tab layout would end up being something like self.components.notebook[0].components.field1, etc. where each page (window) of the notebook is referenced via a list." 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) 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 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? ka |