Tkinter: populating Mac Help menu?

Eric Brunel eric_brunel at despammed.com
Wed Oct 11 11:22:45 CEST 2006


On Tue, 10 Oct 2006 14:29:46 +0200, Edward K. Ream <edreamleo at charter.net>  
wrote:
[snip]
> So given x (a string), how does one create a widget whose name is  
> '%s.help'
> % x ?  This is a can of corn in Tk, but nothing comes to mind looking at  
> the
> Tkinter source code.

Use the 'name' keyword when creating the menu itself:

----------------------------------------------------
 from Tkinter import *

root = Tk()

mb = Menu(root)
root.configure(menu=mb)

## Normal menu
fm = Menu(mb)
fm.add_command(label='Quit', command=root.quit)
mb.add_cascade(label='File', menu=fm)

## Help menu with a specific name
hm = Menu(mb, name='help')
hm.add_command(label='About...')
mb.add_cascade(label='Help', menu=hm)

root.mainloop()
----------------------------------------------------

I didn't test it on MacOS-X, but the same trick should be used when  
creating help menus on Unix (this menu is supposed to appear at the right  
of the menubar according to Motif conventions).

HTH
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"



More information about the Python-list mailing list