[Tkinter-discuss] Context-sensitive help for a menu bar
ceball at gmail.com
Mon Apr 9 06:26:12 CEST 2007
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:
### Create a native menu bar
self.menubar = Tkinter.Menu(self)
self.example_menu = Tkinter.Menu(self.menubar,tearoff=0)
self.another_menu = Tkinter.Menu(self.menubar,tearoff=0)
print "example 1"
print "example 2"
print "example 3"
print "example 4"
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()
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
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,
More information about the Tkinter-discuss