469,610 Members | 1,774 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,610 developers. It's quick & easy.

Tkinter: populating Mac Help menu?

Hello all,

Creating a 'Help' menu 'by hand' on the Mac does not work, or rather, it
creates a *second* Help menu.

There are hints about how to do this at:

http://tkinter.unpythonic.net/wiki/Widgets/Menu

but so far those hints have not been enough :-) The following statements are
the result of several happy hours experimenting with dir(obj) for several
objects obj related to menus. (Jeeze, I love Python, but you knew that :-)

The url above suggests that the 'official' Mac menu is named x.help, where x
is the Tk name (a string) of the menubar. If menubar is the Tkinter menubar
widget, then I assume that x = menubar._w.

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.

If my app does *not* create a help menu, then even long after the Mac
menubar is created, and the official (empty) Help menu is visible,
menubar.children does *not* contain an entry for the official Mac Help menu.
Thus, there appears to be no way to populate the official Help menu after
letting Tkinter create the Help menu. Naturally, I could be wrong :-)

Thanks for any help you can provide.
Edward
--------------------------------------------------------------------
Edward K. Ream email: ed*******@charter.net
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------
Oct 10 '06 #1
4 1788
"Edward K. Ream" <ed*******@charter.netwrites:
Creating a 'Help' menu 'by hand' on the Mac does not work, or
rather, it creates a *second* Help menu.
Presuming you are talking about MacOS X, it doesn't for me.
See Gato from http://gato.sourceforge.net/Download/

The menu code is at <http://svn.sourceforge.net/viewvc/gato/
trunk/Gato/Gato.py?revision=275&view=markup>

Alexander

--
Alexander Schliep sc*****@molgen.mpg.de http://algorithmics.molgen.mpg.de
Oct 11 '06 #2
On Tue, 10 Oct 2006 14:29:46 +0200, Edward K. Ream <ed*******@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+-'])"
Oct 11 '06 #3
Thanks for these replies. I'll try these ideas soon and report back on my
experiences.

Edward
--------------------------------------------------------------------
Edward K. Ream email: ed*******@charter.net
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------
Oct 11 '06 #4
hm = Menu(mb, name='help')

Yes, that worked. Many thanks for your help with Help.

Edward
--------------------------------------------------------------------
Edward K. Ream email: ed*******@charter.net
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------
Oct 15 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.