Hi, I'm trying to make a gui that consists of a window with a menu bar, and for context-sensitive help to be displayed for the menu items.
Right now I have a Toplevel window with a Pmw MainMenuBar and StatusBar. I have context-senstive help for items on the menus by using Pmw's Balloon, and directing the help to the StatusBar. The context-sensitive help displays on linux, but it doesn't on Windows XP (and on OS X - although I'm not sure there if OS X programs ever have such a status bar). According to http://pmw.sourceforge.net/doc/bugs.html, this could be a known problem (although it refers to MenuBar, not MainMenuBar): """ On NT, Pmw.MenuBar does not display message bar help for menu items. It seems that Tk menu widgets do not support <Motion> events on MS. This probably is an issue that should be taken up with the Tcl/Tk people. (Reported by Stefan Schone. Pmw.0.7) """ I've tried myself to implement context-sensitive help using the <<MenuSelect>> event and then finding the menu's active index - as suggested at http://tkinter.unpythonic.net/wiki/Widgets/Menu: """ Whenever a menu's active entry is changed, a <<MenuSelect>> virtual event is sent to the menu. The active item can then be queried from the menu, and an action can be taken, such as setting context-sensitive help text for the entry. """ For me, the active index always comes back as None, whatever I try! Here is an example of some code I've been using: <code> import Tkinter class Console(Tkinter.Tk): def __init__(self,**config): Tkinter.Tk.__init__(self,**config) ### Create a native menu bar self.menubar = Tkinter.Menu(self) self.configure(menu=self.menubar) self.example_menu = Tkinter.Menu(self.menubar,tearoff=0) self.example_menu.add_command(label="Example 1",command=self.example1) self.example_menu.add_command(label="Example 2",command=self.example2) self.menubar.add_cascade(label="Example",menu=self.example_menu) self.another_menu = Tkinter.Menu(self.menubar,tearoff=0) self.another_menu.add_command(label="Example 3",command=self.example3) self.another_menu.add_command(label="Example 4",command=self.example4) self.menubar.add_cascade(label="Another",menu=self.another_menu) self.menubar.bind("<<MenuSelect>>",self.menu_select) #self.example_menu.bind("<<MenuSelect>>",self.menu_select) #self.another_menu.bind("<<MenuSelect>>",self.menu_select) def example1(self): print "example 1" def example2(self): print "example 2" def example3(self): print "example 3" def example4(self): print "example 4" def menu_select(self,event): print "menubar's active index=",self.menubar.index('active') #print "example_menu's active index=",self.example_menu.index('active') #print "another_menu's active index=",self.another_menu.index('active') c = Console() </code> I'd really like to have a main window for my gui that includes a menu bar, and some way of displaying context-sensitive help for menu items. Could anyone help me to make this example of detecting the active menu item work, or point me in the direction of an application that uses Tkinter and has context-sensitive menu help working on linux and Windows? I've noticed bwidget.MainFrame, which seems like it would be great - if its DynamicHelp features work on the various platforms (and if I could figure out the documentation). Does anyone know? Could anyone point me to a Python application that uses bwidget.MainFrame, or provide a simple example of its use? Or anything similar to it? Thanks very much, Chris _______________________________________________ Tkinter-discuss mailing list [email protected] http://mail.python.org/mailman/listinfo/tkinter-discuss
