From: <bra...@om...> - 2005-03-28 23:01:53
|
I meant to say, self.menuBar = wx.GetTopLevelParent(self).menuBar Brad Allen/Dallas wrote on 03/28/2005 04:57:29 PM: > > Now I'm trying this within the tabs (Notebook pages): > > self.menuBar = self.wx.GetTopLevelParent(self).menuBar > > and then within the child windows: > > self.menuBar = self.getParent().menuBar > > Still not giving me the menu I want in the child windows. > > > pyt...@li... wrote on 03/28/2005 04:31:37 PM: > > > > > Whoops, I must be blind. Apparently PageBackground objects have no > > attribute getParent(). > > > > > > pyt...@li... wrote on 03/28/2005 > 04:21:51 PM: > > > > > > > > So, I've now got a main window with a tabbed interface and a > global menubar > > > that works for all the tabs. However, I still need to spawn a few > > > child windows, and these > > > need to have a copy of the main menubar. I have tried binding the > > > menubar of the > > > parent during the background initialization of the child window,like so: > > > > > > class MyBackground( model.Background): > > > def on_initialize(self, event): > > > self.menuBar = self.getParent().menuBar > > > > > > This doesn't work, although it doesn't seem to generate any > > > exceptions that I can see. > > > I have tried it on child windows whose resource file contains no > > > menubar, and I have tried > > > it on child windows whose resource file contains no menubar. > > > > > > Is there a method for refreshing the menubar? > > > > > > Thanks! > > > > > > "Kevin Altis" <al...@se...> wrote on 03/21/2005 10:25:35 AM: > > > > > > > On Mar 19, 2005, at 7:27 PM, bra...@om... wrote: > > > > > > > > > > > > > > I'm thinking I can get by with a tabbed interface for the > main window, > > > > > and go with small menu-less child windows for some of the individual > > > > > forms. For instance, an Employees tab would show a multiColumnList of > > > > > employees with search filters at the top. To edit an employee record, > > > > > the user doubleclicks a line and an employee edit window > pops up. This > > > > > seems like a workable approach. I guess I need to take a look at how > > > > > to implement the Notebook. > > > > > > > > > > > > > A tabbed interface seems like the way to go. There is currently no > > > > option to toggle the menubar for a window on and off in the > > > > resourceEditor. The reason I didn't do that is if someone made a bunch > > > > of menus and then accidentally got rid of them they would be pretty > > > > upset, and we have no undo feature. Instead when you create your > > > > background by using New under the File menu, select the appropriate > > > > template, for whether you want menus or not. > > > > > > > > The "main" menubar is always available to all windows. On the main > > > > background, it is just self.menuBar so on a child window you would > > > > access it as self.getParent().menuBar. > > > > > > > > When you use a single menubar and child windows, one of the things you > > > > have to watch out for is focus. Your main window will get the focus. If > > > > you run with the Message Watcher you'll see the deactivate, loseFocus, > > > > activate, loseFocus, gainFocus messages fire. Depending on what you > > > > want to do, you'll probably need to use the findFocus() method or some > > > > other method of tracking what is going on in your child window and > > > > saving that information in an on_deactivate method which you would then > > > > access in your main window menu item event handler. > > > > > > > > ka |
From: Liam C. <cy...@gm...> - 2005-03-28 23:41:52
|
---------- Forwarded message ---------- From: Liam Clarke <cy...@gm...> Date: Tue, 29 Mar 2005 11:41:37 +1200 Subject: Re: [Pythoncard-users] global menubar To: "bra...@om..." <bra...@om...> Well, you could try a wx.Yield() to force redraw, but I suspect that's not the answer. Try, and this is silly, but try it anyway, try parent = wx.GetTopLevelParent(self) self.menuBar = parent.menubar Although, you should've had an Attribute Error if that wasn't working right. Try that in the meanwhile, I'll have a poke around my resource files at home. I assume that you've tested it across platforms? Regards, Liam Clarke On Mon, 28 Mar 2005 17:00:54 -0600, bra...@om... <bra...@om...> wrote: > > > I meant to say, > > self.menuBar = wx.GetTopLevelParent(self).menuBar > > Brad Allen/Dallas wrote on 03/28/2005 04:57:29 PM: > > > > > Now I'm trying this within the tabs (Notebook pages): > > > > self.menuBar = self.wx.GetTopLevelParent(self).menuBar > > > > and then within the child windows: > > > > self.menuBar = self.getParent().menuBar > > > > Still not giving me the menu I want in the child windows. > > > > > > pyt...@li... wrote on 03/28/2005 04:31:37 > PM: > > > > > > > > > Whoops, I must be blind. Apparently PageBackground objects have no > > > attribute getParent(). > > > > > > > > > pyt...@li... wrote on 03/28/2005 > > 04:21:51 PM: > > > > > > > > > > > So, I've now got a main window with a tabbed interface and a > > global menubar > > > > that works for all the tabs. However, I still need to spawn a few > > > > child windows, and these > > > > need to have a copy of the main menubar. I have tried binding the > > > > menubar of the > > > > parent during the background initialization of the child window,like > so: > > > > > > > > class MyBackground( model.Background): > > > > def on_initialize(self, event): > > > > self.menuBar = self.getParent().menuBar > > > > > > > > This doesn't work, although it doesn't seem to generate any > > > > exceptions that I can see. > > > > I have tried it on child windows whose resource file contains no > > > > menubar, and I have tried > > > > it on child windows whose resource file contains no menubar. > > > > > > > > Is there a method for refreshing the menubar? > > > > > > > > Thanks! > > > > > > > > "Kevin Altis" <al...@se...> wrote on 03/21/2005 10:25:35 > AM: > > > > > > > > > On Mar 19, 2005, at 7:27 PM, bra...@om... wrote: > > > > > > > > > > > > > > > > > I'm thinking I can get by with a tabbed interface for the > > main window, > > > > > > and go with small menu-less child windows for some of the > individual > > > > > > forms. For instance, an Employees tab would show a > multiColumnList of > > > > > > employees with search filters at the top. To edit an employee > record, > > > > > > the user doubleclicks a line and an employee edit window > > pops up. This > > > > > > seems like a workable approach. I guess I need to take a look at > how > > > > > > to implement the Notebook. > > > > > > > > > > > > > > > > A tabbed interface seems like the way to go. There is currently no > > > > > option to toggle the menubar for a window on and off in the > > > > > resourceEditor. The reason I didn't do that is if someone made a > bunch > > > > > of menus and then accidentally got rid of them they would be pretty > > > > > upset, and we have no undo feature. Instead when you create your > > > > > background by using New under the File menu, select the appropriate > > > > > template, for whether you want menus or not. > > > > > > > > > > The "main" menubar is always available to all windows. On the main > > > > > background, it is just self.menuBar so on a child window you would > > > > > access it as self.getParent().menuBar. > > > > > > > > > > When you use a single menubar and child windows, one of the things > you > > > > > have to watch out for is focus. Your main window will get the > focus. If > > > > > you run with the Message Watcher you'll see the deactivate, > loseFocus, > > > > > activate, loseFocus, gainFocus messages fire. Depending on what you > > > > > want to do, you'll probably need to use the findFocus() method or > some > > > > > other method of tracking what is going on in your child window and > > > > > saving that information in an on_deactivate method which you would > then > > > > > access in your main window menu item event handler. > > > > > > > > > > ka -- 'There is only one basic human right, and that is to do as you damn well please. And with it comes the only basic human duty, to take the consequences. -- 'There is only one basic human right, and that is to do as you damn well please. And with it comes the only basic human duty, to take the consequences. |
From: <bra...@om...> - 2005-03-29 04:52:03
|
I haven't tried it on Mac, partially because the menus are automatically global on the Mac side. The wx.Yield() didn't have any effect, either. I tried a few other variants, including the parent binding on a separate line as you suggested. Still no luck. Here is my background class as it currently stands: class MyBackground (MycroftEventTrapper, model.Background): def on_initialize(self, event): # parent is a PageBackground, grandparent is background "MainWindow" # since a PageBackground has no getParent() method, # instead use wx.GetTopLevelParent parent = wx.GetTopLevelParent(self.getParent()) print 'parent:', parent # prints __main__.MainWindow self.menuBar = parent.menuBar self.Raise() #bring window forward wx.Yield() # refresh? Doesn't make menu change Liam Clarke <cy...@gm...> wrote on 03/28/2005 05:41:37 PM: > Well, you could try a wx.Yield() to force redraw, but I suspect that's > not the answer. > > Try, and this is silly, but try it anyway, try > > parent = wx.GetTopLevelParent(self) > self.menuBar = parent.menubar > > Although, you should've had an Attribute Error if that wasn't working right. > > Try that in the meanwhile, I'll have a poke around my resource filesat home. > I assume that you've tested it across platforms? > > Regards, > > Liam Clarke > > On Mon, 28 Mar 2005 17:00:54 -0600, bra...@om... > <bra...@om...> wrote: > > > > > > I meant to say, > > > > self.menuBar = wx.GetTopLevelParent(self).menuBar > > > > Brad Allen/Dallas wrote on 03/28/2005 04:57:29 PM: > > > > > > > > Now I'm trying this within the tabs (Notebook pages): > > > > > > self.menuBar = self.wx.GetTopLevelParent(self).menuBar > > > > > > and then within the child windows: > > > > > > self.menuBar = self.getParent().menuBar > > > > > > Still not giving me the menu I want in the child windows. > > > > > > > > > pyt...@li... wrote on 03/28/2005 04:31:37 > > PM: > > > > > > > > > > > > > Whoops, I must be blind. Apparently PageBackground objects have no > > > > attribute getParent(). > > > > > > > > > > > > pyt...@li... wrote on 03/28/2005 > > > 04:21:51 PM: > > > > > > > > > > > > > > So, I've now got a main window with a tabbed interface and a > > > global menubar > > > > > that works for all the tabs. However, I still need to spawn a few > > > > > child windows, and these > > > > > need to have a copy of the main menubar. I have tried binding the > > > > > menubar of the > > > > > parent during the background initialization of the child window,like > > so: > > > > > > > > > > class MyBackground( model.Background): > > > > > def on_initialize(self, event): > > > > > self.menuBar = self.getParent().menuBar > > > > > > > > > > This doesn't work, although it doesn't seem to generate any > > > > > exceptions that I can see. > > > > > I have tried it on child windows whose resource file contains no > > > > > menubar, and I have tried > > > > > it on child windows whose resource file contains no menubar. > > > > > > > > > > Is there a method for refreshing the menubar? > > > > > > > > > > Thanks! > > > > > > > > > > "Kevin Altis" <al...@se...> wrote on 03/21/2005 10:25:35 > > AM: > > > > > > > > > > > On Mar 19, 2005, at 7:27 PM, bra...@om... wrote: > > > > > > > > > > > > > > > > > > > > I'm thinking I can get by with a tabbed interface for the > > > main window, > > > > > > > and go with small menu-less child windows for some of the > > individual > > > > > > > forms. For instance, an Employees tab would show a > > multiColumnList of > > > > > > > employees with search filters at the top. To edit an employee > > record, > > > > > > > the user doubleclicks a line and an employee edit window > > > pops up. This > > > > > > > seems like a workable approach. I guess I need to take a look at > > how > > > > > > > to implement the Notebook. > > > > > > > > > > > > > > > > > > > A tabbed interface seems like the way to go. There is currently no > > > > > > option to toggle the menubar for a window on and off in the > > > > > > resourceEditor. The reason I didn't do that is if someone made a > > bunch > > > > > > of menus and then accidentally got rid of them they wouldbe pretty > > > > > > upset, and we have no undo feature. Instead when you create your > > > > > > background by using New under the File menu, select the appropriate > > > > > > template, for whether you want menus or not. > > > > > > > > > > > > The "main" menubar is always available to all windows. Onthe main > > > > > > background, it is just self.menuBar so on a child window you would > > > > > > access it as self.getParent().menuBar. > > > > > > > > > > > > When you use a single menubar and child windows, one of the things > > you > > > > > > have to watch out for is focus. Your main window will get the > > focus. If > > > > > > you run with the Message Watcher you'll see the deactivate, > > loseFocus, > > > > > > activate, loseFocus, gainFocus messages fire. Depending on what you > > > > > > want to do, you'll probably need to use the findFocus() method or > > some > > > > > > other method of tracking what is going on in your child window and > > > > > > saving that information in an on_deactivate method which you would > > then > > > > > > access in your main window menu item event handler. > > > > > > > > > > > > ka > > > -- > 'There is only one basic human right, and that is to do as you damn > well please. > And with it comes the only basic human duty, to take the consequences. |
From: Liam C. <cy...@gm...> - 2005-03-29 08:34:16
Attachments:
testMenu.rar
|
Hey Brad, You may want to copy and paste the following code. I poked around model.py in the bowels of Background, and here's how model.Background sets a menu - def _createMenus(self, aResource): # RDS - Only create a menubar if one is defined # in the stack's resource file. # This is a hack, I shouldn't be accessing # the stack resource's __dict)__ directly. if ('menubar' in aResource.__dict__) and (aResource.menubar is not None): self.menuBar = menu.MenuBar(self, aResource.menubar) elif wx.Platform == '__WXMAC__' and self.GetParent() is None: # always create at least a File menu with Quit on the Mac # so we automatically get the Apple menu... # KEA 2004-03-01 # the elif was updated to make sure we only create a menubar # if the background has no parent, aka is the primary app window self._createMacMenu() # KEA and as a further hack, I now add a Debug menu # to the menubar. createMenu will create a menubar # if one doesn't already exist if self.application._showDebugMenu and self.GetParent() == None: self.application._debugMenu = debug.DebugMenu(self.application) self.application._debugMenu.createMenu(self) self.application._debugMenu.bindMenuEvents(self) Alrighty, lots of private methods there. But, the important part is from Pythoncard import menu and self.menuBar = menu.MenuBar(self, aResource.menubar) So... I present, my <drum roll> sample cooooooooodddddddde!!!! http://www.rafb.net/paste/results/Cm4rdR68.html I've also attached a rar file of the code and the resource files. I really, really, hope that helps. Regards, Liam Clarke On Mon, 28 Mar 2005 22:51:16 -0600, bra...@om... <bra...@om...> wrote: > > I haven't tried it on Mac, partially because the menus are automatically > global on the Mac side. > > The wx.Yield() didn't have any effect, either. I tried a few other variants, > including the parent binding > on a separate line as you suggested. Still no luck. Here is my background > class as it currently stands: > > > class MyBackground (MycroftEventTrapper, model.Background): > def on_initialize(self, event): > # parent is a PageBackground, grandparent is background > "MainWindow" > # since a PageBackground has no getParent() method, > # instead use wx.GetTopLevelParent > > parent = wx.GetTopLevelParent(self.getParent()) > print 'parent:', parent # prints > __main__.MainWindow > self.menuBar = parent.menuBar > self.Raise() #bring window forward > wx.Yield() # refresh? Doesn't make menu change > > > Liam Clarke <cy...@gm...> wrote on 03/28/2005 05:41:37 PM: > > > Well, you could try a wx.Yield() to force redraw, but I suspect that's > > not the answer. > > > > Try, and this is silly, but try it anyway, try > > > > parent = wx.GetTopLevelParent(self) > > self.menuBar = parent.menubar > > > > Although, you should've had an Attribute Error if that wasn't working > right. > > > > Try that in the meanwhile, I'll have a poke around my resource filesat > home. > > > I assume that you've tested it across platforms? > > > > Regards, > > > > Liam Clarke > > > > On Mon, 28 Mar 2005 17:00:54 -0600, bra...@om... > > <bra...@om...> wrote: > > > > > > > > > I meant to say, > > > > > > self.menuBar = wx.GetTopLevelParent(self).menuBar > > > > > > Brad Allen/Dallas wrote on 03/28/2005 04:57:29 PM: > > > > > > > > > > > Now I'm trying this within the tabs (Notebook pages): > > > > > > > > self.menuBar = self.wx.GetTopLevelParent(self).menuBar > > > > > > > > and then within the child windows: > > > > > > > > self.menuBar = self.getParent().menuBar > > > > > > > > Still not giving me the menu I want in the child windows. > > > > > > > > > > > > pyt...@li... wrote on 03/28/2005 > 04:31:37 > > > PM: > > > > > > > > > > > > > > > > > Whoops, I must be blind. Apparently PageBackground objects have no > > > > > attribute getParent(). > > > > > > > > > > > > > > > pyt...@li... wrote on 03/28/2005 > > > > 04:21:51 PM: > > > > > > > > > > > > > > > > > So, I've now got a main window with a tabbed interface and a > > > > global menubar > > > > > > that works for all the tabs. However, I still need to spawn a > few > > > > > > child windows, and these > > > > > > need to have a copy of the main menubar. I have tried binding > the > > > > > > menubar of the > > > > > > parent during the background initialization of the child > window,like > > > so: > > > > > > > > > > > > class MyBackground( model.Background): > > > > > > def on_initialize(self, event): > > > > > > self.menuBar = self.getParent().menuBar > > > > > > > > > > > > This doesn't work, although it doesn't seem to generate any > > > > > > exceptions that I can see. > > > > > > I have tried it on child windows whose resource file contains no > > > > > > menubar, and I have tried > > > > > > it on child windows whose resource file contains no menubar. > > > > > > > > > > > > Is there a method for refreshing the menubar? > > > > > > > > > > > > Thanks! > > > > > > > > > > > > "Kevin Altis" <al...@se...> wrote on 03/21/2005 > 10:25:35 > > > AM: > > > > > > > > > > > > > On Mar 19, 2005, at 7:27 PM, bra...@om... wrote: > > > > > > > > > > > > > > > > > > > > > > > I'm thinking I can get by with a tabbed interface for the > > > > main window, > > > > > > > > and go with small menu-less child windows for some of the > > > individual > > > > > > > > forms. For instance, an Employees tab would show a > > > multiColumnList of > > > > > > > > employees with search filters at the top. To edit an > employee > > > record, > > > > > > > > the user doubleclicks a line and an employee edit window > > > > pops up. This > > > > > > > > seems like a workable approach. I guess I need to take a > look at > > > how > > > > > > > > to implement the Notebook. > > > > > > > > > > > > > > > > > > > > > > A tabbed interface seems like the way to go. There is > currently no > > > > > > > option to toggle the menubar for a window on and off in the > > > > > > > resourceEditor. The reason I didn't do that is if someone made > a > > > bunch > > > > > > > of menus and then accidentally got rid of them they wouldbe > pretty > > > > > > > upset, and we have no undo feature. Instead when you create > your > > > > > > > background by using New under the File menu, select the > appropriate > > > > > > > template, for whether you want menus or not. > > > > > > > > > > > > > > The "main" menubar is always available to all windows. Onthe > main > > > > > > > background, it is just self.menuBar so on a child window you > would > > > > > > > access it as self.getParent().menuBar. > > > > > > > > > > > > > > When you use a single menubar and child windows, one of the > things > > > you > > > > > > > have to watch out for is focus. Your main window will get the > > > focus. If > > > > > > > you run with the Message Watcher you'll see the deactivate, > > > loseFocus, > > > > > > > activate, loseFocus, gainFocus messages fire. Depending on > what you > > > > > > > want to do, you'll probably need to use the findFocus() method > or > > > some > > > > > > > other method of tracking what is going on in your child window > and > > > > > > > saving that information in an on_deactivate method which you > would > > > then > > > > > > > access in your main window menu item event handler. > > > > > > > > > > > > > > ka > > > > > > -- > > 'There is only one basic human right, and that is to do as you damn > > well please. > > And with it comes the only basic human duty, to take the consequences. > -- 'There is only one basic human right, and that is to do as you damn well please. And with it comes the only basic human duty, to take the consequences. |
From: Brad A. <bra...@ma...> - 2005-03-29 14:34:49
|
Thanks, Liam! I'll try it when I get to work today. It looks like the key difference from what I was trying to do is to use a constructor for the menubar and then run the Show method. self.menuBar = menu.MenuBar(self, self.parent.menuBar) self.Show(1) >Hey Brad, > >You may want to copy and paste the following code. I poked around >model.py in the bowels of Background, and here's how model.Background >sets a menu - > >def _createMenus(self, aResource): > # RDS - Only create a menubar if one is defined > # in the stack's resource file. > # This is a hack, I shouldn't be accessing > # the stack resource's __dict)__ directly. > if ('menubar' in aResource.__dict__) and (aResource.menubar is >not None): > self.menuBar = menu.MenuBar(self, aResource.menubar) > elif wx.Platform == '__WXMAC__' and self.GetParent() is None: > # always create at least a File menu with Quit on the Mac > # so we automatically get the Apple menu... > # KEA 2004-03-01 > # the elif was updated to make sure we only create a menubar > # if the background has no parent, aka is the primary app window > self._createMacMenu() > > # KEA and as a further hack, I now add a Debug menu > # to the menubar. createMenu will create a menubar > # if one doesn't already exist > if self.application._showDebugMenu and self.GetParent() == None: > self.application._debugMenu = debug.DebugMenu(self.application) > self.application._debugMenu.createMenu(self) > self.application._debugMenu.bindMenuEvents(self) > > >Alrighty, lots of private methods there. But, the important part is >from Pythoncard import menu > >and > >self.menuBar = menu.MenuBar(self, aResource.menubar) > >So... I present, my <drum roll> sample cooooooooodddddddde!!!! > >http://www.rafb.net/paste/results/Cm4rdR68.html > >I've also attached a rar file of the code and the resource files. > >I really, really, hope that helps. > > >Regards, > >Liam Clarke >On Mon, 28 Mar 2005 22:51:16 -0600, bra...@om... ><bra...@om...> wrote: >> >> I haven't tried it on Mac, partially because the menus are automatically >> global on the Mac side. >> >> The wx.Yield() didn't have any effect, either. I tried a few other variants, >> including the parent binding >> on a separate line as you suggested. Still no luck. Here is my background >> class as it currently stands: >> >> >> class MyBackground (MycroftEventTrapper, model.Background): >> def on_initialize(self, event): >> # parent is a PageBackground, grandparent is background >> "MainWindow" >> # since a PageBackground has no getParent() method, >> # instead use wx.GetTopLevelParent >> >> parent = wx.GetTopLevelParent(self.getParent()) >> print 'parent:', parent # prints >> __main__.MainWindow >> self.menuBar = parent.menuBar >> self.Raise() #bring window forward >> wx.Yield() # refresh? Doesn't make menu change >> >> >> Liam Clarke <cy...@gm...> wrote on 03/28/2005 05:41:37 PM: >> >> > Well, you could try a wx.Yield() to force redraw, but I suspect that's >> > not the answer. > > > >> > Try, and this is silly, but try it anyway, try >> > >> > parent = wx.GetTopLevelParent(self) >> > self.menuBar = parent.menubar >> > >> > Although, you should've had an Attribute Error if that wasn't working >> right. >> > >> > Try that in the meanwhile, I'll have a poke around my resource filesat >> home. >> >> > I assume that you've tested it across platforms? >> > >> > Regards, >> > >> > Liam Clarke >> > >> > On Mon, 28 Mar 2005 17:00:54 -0600, bra...@om... >> > <bra...@om...> wrote: >> > > >> > > >> > > I meant to say, >> > > >> > > self.menuBar = wx.GetTopLevelParent(self).menuBar >> > > >> > > Brad Allen/Dallas wrote on 03/28/2005 04:57:29 PM: > > > > >> > > > >> > > > Now I'm trying this within the tabs (Notebook pages): >> > > > >> > > > self.menuBar = self.wx.GetTopLevelParent(self).menuBar >> > > > >> > > > and then within the child windows: >> > > > >> > > > self.menuBar = self.getParent().menuBar >> > > > >> > > > Still not giving me the menu I want in the child windows. >> > > > >> > > > >> > > > pyt...@li... wrote on 03/28/2005 >> 04:31:37 >> > > PM: >> > > >> > > > >> > > > > >> > > > > Whoops, I must be blind. Apparently PageBackground objects have no >> > > > > attribute getParent(). >> > > > > >> > > > > >> > > > > pyt...@li... wrote on 03/28/2005 >> > > > 04:21:51 PM: >> > > > > >> > > > > > >> > > > > > So, I've now got a main window with a tabbed interface and a >> > > > global menubar >> > > > > > that works for all the tabs. However, I still need to spawn a >> few >> > > > > > child windows, and these >> > > > > > need to have a copy of the main menubar. I have tried binding >> the >> > > > > > menubar of the >> > > > > > parent during the background initialization of the child >> window,like >> > > so: >> > > > > > >> > > > > > class MyBackground( model.Background): >> > > > > > def on_initialize(self, event): >> > > > > > self.menuBar = self.getParent().menuBar >> > > > > > >> > > > > > This doesn't work, although it doesn't seem to generate any >> > > > > > exceptions that I can see. >> > > > > > I have tried it on child windows whose resource file contains no >> > > > > > menubar, and I have tried >> > > > > > it on child windows whose resource file contains no menubar. >> > > > > > >> > > > > > Is there a method for refreshing the menubar? >> > > > > > >> > > > > > Thanks! >> > > > > > >> > > > > > "Kevin Altis" <al...@se...> wrote on 03/21/2005 >> 10:25:35 >> > > AM: >> > > > > > >> > > > > > > On Mar 19, 2005, at 7:27 PM, bra...@om... wrote: >> > > > > > > >> > > > > > > > >> > > > > > > > I'm thinking I can get by with a tabbed interface for the >> > > > main window, >> > > > > > > > and go with small menu-less child windows for some of the >> > > individual >> > > > > > > > forms. For instance, an Employees tab would show a >> > > multiColumnList of >> > > > > > > > employees with search filters at the top. To edit an >> employee >> > > record, >> > > > > > > > the user doubleclicks a line and an employee edit window >> > > > pops up. This >> > > > > > > > seems like a workable approach. I guess I need to take a >> look at >> > > how >> > > > > > > > to implement the Notebook. >> > > > > > > > >> > > > > > > >> > > > > > > A tabbed interface seems like the way to go. There is >> currently no >> > > > > > > option to toggle the menubar for a window on and off in the >> > > > > > > resourceEditor. The reason I didn't do that is if someone made >> a >> > > bunch >> > > > > > > of menus and then accidentally got rid of them they wouldbe >> pretty >> > > > > > > upset, and we have no undo feature. Instead when you create >> your >> > > > > > > background by using New under the File menu, select the >> appropriate >> > > > > > > template, for whether you want menus or not. >> > > > > > > >> > > > > > > The "main" menubar is always available to all windows. Onthe > > main >> > > > > > > background, it is just self.menuBar so on a child window you >> would >> > > > > > > access it as self.getParent().menuBar. >> > > > > > > >> > > > > > > When you use a single menubar and child windows, one of the >> things >> > > you >> > > > > > > have to watch out for is focus. Your main window will get the >> > > focus. If >> > > > > > > you run with the Message Watcher you'll see the deactivate, >> > > loseFocus, >> > > > > > > activate, loseFocus, gainFocus messages fire. Depending on >> what you >> > > > > > > want to do, you'll probably need to use the findFocus() method >> or >> > > some >> > > > > > > other method of tracking what is going on in your child window >> and >> > > > > > > saving that information in an on_deactivate method which you > > would >> > > then >> > > > > > > access in your main window menu item event handler. >> > > > > > > >> > > > > > > ka >> > >> > >> > -- >> > 'There is only one basic human right, and that is to do as you damn >> > well please. >> > And with it comes the only basic human duty, to take the consequences. >> > > >-- >'There is only one basic human right, and that is to do as you damn >well please. >And with it comes the only basic human duty, to take the consequences. > >Attachment converted: Macintosh HD:testMenu.rar ( / ) (0006D0E6) |
From: <bra...@om...> - 2005-03-30 18:23:40
|
Thanks, Liam. Your approach of the using the PythonCard MenuBar constructor has worked for me. from PythonCard import menu menu.MenuBar(self, self.getParent().menuBar) In cases where a child window is the child of a PageBackground, I just store the wx.GetTopLevelParent(self).menuBar in the PageBackground, and the child window can obtain it from there. |
From: Liam C. <cy...@gm...> - 2005-03-29 19:20:21
|
I wouldn't worry too much about the Show method, I just have visible set to False by default for most of my windows. I'm a control freak. ;) On Tue, 29 Mar 2005 08:34:49 -0600, Brad Allen <bra...@ma...> wrote: > > > > Thanks, Liam! I'll try it when I get to work today. It looks like the key > difference from what I was trying to do is to use a constructor for the > menubar and then run the Show method. > > > self.menuBar = menu.MenuBar(self, self.parent.menuBar) > self.Show(1) > > > > > > > > Hey Brad, > > You may want to copy and paste the following code. I poked around > model.py in the bowels of Background, and here's how model.Background > sets a menu - > > def _createMenus(self, aResource): > # RDS - Only create a menubar if one is defined > # in the stack's resource file. > # This is a hack, I shouldn't be accessing > # the stack resource's __dict)__ directly. > if ('menubar' in aResource.__dict__) and (aResource.menubar is > not None): > self.menuBar = menu.MenuBar(self, aResource.menubar) > elif wx.Platform == '__WXMAC__' and self.GetParent() is None: > # always create at least a File menu with Quit on the Mac > # so we automatically get the Apple menu... > # KEA 2004-03-01 > # the elif was updated to make sure we only create a menubar > # if the background has no parent, aka is the primary app > window > self._createMacMenu() > > # KEA and as a further hack, I now add a Debug menu > # to the menubar. createMenu will create a menubar > # if one doesn't already exist > if self.application._showDebugMenu and self.GetParent() == None: > self.application._debugMenu = debug.DebugMenu(self.application) > self.application._debugMenu.createMenu(self) > self.application._debugMenu.bindMenuEvents(self) > > > Alrighty, lots of private methods there. But, the important part is > from Pythoncard import menu > > and > > self.menuBar = menu.MenuBar(self, aResource.menubar) > > So... I present, my <drum roll> sample cooooooooodddddddde!!!! > > http://www.rafb.net/paste/results/Cm4rdR68.html > > I've also attached a rar file of the code and the resource files. > > I really, really, hope that helps. > > > Regards, > > Liam Clarke > On Mon, 28 Mar 2005 22:51:16 -0600, bra...@om... > <bra...@om...> wrote: > > > > I haven't tried it on Mac, partially because the menus are automatically > > global on the Mac side. > > > > The wx.Yield() didn't have any effect, either. I tried a few other > variants, > > including the parent binding > > on a separate line as you suggested. Still no luck. Here is my background > > class as it currently stands: > > > > > > class MyBackground (MycroftEventTrapper, model.Background): > > def on_initialize(self, event): > > # parent is a PageBackground, grandparent is background > > "MainWindow" > > # since a PageBackground has no getParent() method, > > # instead use wx.GetTopLevelParent > > > > parent = wx.GetTopLevelParent(self.getParent()) > > print 'parent:', parent # prints > > __main__.MainWindow > > self.menuBar = parent.menuBar > > self.Raise() #bring window forward > > wx.Yield() # refresh? Doesn't make menu change > > > > > > Liam Clarke <cy...@gm...> wrote on 03/28/2005 05:41:37 PM: > > > > > Well, you could try a wx.Yield() to force redraw, but I suspect that's > > > not the answer. > > > > > > Try, and this is silly, but try it anyway, try > > > > > > parent = wx.GetTopLevelParent(self) > > > self.menuBar = parent.menubar > > > > > > Although, you should've had an Attribute Error if that wasn't working > > right. > > > > > > Try that in the meanwhile, I'll have a poke around my resource filesat > > home. > > > > > I assume that you've tested it across platforms? > > > > > > Regards, > > > > > > Liam Clarke > > > > > > On Mon, 28 Mar 2005 17:00:54 -0600, bra...@om... > > > <bra...@om...> wrote: > > > > > > > > > > > > I meant to say, > > > > > > > > self.menuBar = wx.GetTopLevelParent(self).menuBar > > > > > > > > Brad Allen/Dallas wrote on 03/28/2005 04:57:29 PM: > > > > > > > > > > > > > > Now I'm trying this within the tabs (Notebook pages): > > > > > > > > > > self.menuBar = self.wx.GetTopLevelParent(self).menuBar > > > > > > > > > > and then within the child windows: > > > > > > > > > > self.menuBar = self.getParent().menuBar > > > > > > > > > > Still not giving me the menu I want in the child windows. > > > > > > > > > > > > > > > pyt...@li... wrote on 03/28/2005 > > 04:31:37 > > > > PM: > > > > > > > > > > > > > > > > > > > > > Whoops, I must be blind. Apparently PageBackground objects have > no > > > > > > attribute getParent(). > > > > > > > > > > > > > > > > > > pyt...@li... wrote on > 03/28/2005 > > > > > 04:21:51 PM: > > > > > > > > > > > > > > > > > > > > So, I've now got a main window with a tabbed interface and a > > > > > global menubar > > > > > > > that works for all the tabs. However, I still need to spawn a > > few > > > > > > > child windows, and these > > > > > > > need to have a copy of the main menubar. I have tried binding > > the > > > > > > > menubar of the > > > > > > > parent during the background initialization of the child > > window,like > > > > so: > > > > > > > > > > > > > > class MyBackground( model.Background): > > > > > > > def on_initialize(self, event): > > > > > > > self.menuBar = self.getParent().menuBar > > > > > > > > > > > > > > This doesn't work, although it doesn't seem to generate any > > > > > > > exceptions that I can see. > > > > > > > I have tried it on child windows whose resource file contains > no > > > > > > > menubar, and I have tried > > > > > > > it on child windows whose resource file contains no menubar. > > > > > > > > > > > > > > Is there a method for refreshing the menubar? > > > > > > > > > > > > > > Thanks! > > > > > > > > > > > > > > "Kevin Altis" <al...@se...> wrote on 03/21/2005 > > 10:25:35 > > > > AM: > > > > > > > > > > > > > > > On Mar 19, 2005, at 7:27 PM, bra...@om... wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > I'm thinking I can get by with a tabbed interface for the > > > > > main window, > > > > > > > > > and go with small menu-less child windows for some of the > > > > individual > > > > > > > > > forms. For instance, an Employees tab would show a > > > > multiColumnList of > > > > > > > > > employees with search filters at the top. To edit an > > employee > > > > record, > > > > > > > > > the user doubleclicks a line and an employee edit window > > > > > pops up. This > > > > > > > > > seems like a workable approach. I guess I need to take a > > look at > > > > how > > > > > > > > > to implement the Notebook. > > > > > > > > > > > > > > > > > > > > > > > > > A tabbed interface seems like the way to go. There is > > currently no > > > > > > > > option to toggle the menubar for a window on and off in the > > > > > > > > resourceEditor. The reason I didn't do that is if someone > made > > a > > > > bunch > > > > > > > > of menus and then accidentally got rid of them they wouldbe > > pretty > > > > > > > > upset, and we have no undo feature. Instead when you create > > your > > > > > > > > background by using New under the File menu, select the > > appropriate > > > > > > > > template, for whether you want menus or not. > > > > > > > > > > > > > > > > The "main" menubar is always available to all windows. > Onthe > > main > > > > > > > > background, it is just self.menuBar so on a child window > you > > would > > > > > > > > access it as self.getParent().menuBar. > > > > > > > > > > > > > > > > When you use a single menubar and child windows, one of the > > things > > > > you > > > > > > > > have to watch out for is focus. Your main window will get > the > > > > focus. If > > > > > > > > you run with the Message Watcher you'll see the deactivate, > > > > loseFocus, > > > > > > > > activate, loseFocus, gainFocus messages fire. Depending on > > what you > > > > > > > > want to do, you'll probably need to use the findFocus() > method > > or > > > > some > > > > > > > > other method of tracking what is going on in your child > window > > and > > > > > > > > saving that information in an on_deactivate method which > you > > would > > > > then > > > > > > > > access in your main window menu item event handler. > > > > > > > > > > > > > > > > ka > > > > > > > > > -- > > > 'There is only one basic human right, and that is to do as you damn > > > well please. > > > And with it comes the only basic human duty, to take the consequences. > > > > > -- > 'There is only one basic human right, and that is to do as you damn well > please. > And with it comes the only basic human duty, to take the consequences. > > Attachment converted: Macintosh HD:testMenu.rar ( / ) (0006D0E6) > > -- 'There is only one basic human right, and that is to do as you damn well please. And with it comes the only basic human duty, to take the consequences. |