[Tkinter-discuss] a couple of mac menu problems
kw at codebykevin.com
Fri Jun 15 15:45:58 CEST 2012
Please see my answers below:
> Here's a bit of code used to create the Help menu:
> if MAC:
> self.master.createcommand("tkAboutDialog", self.about_action)
> helpMenu = tk.Menu(self.menubar, name="help")
> helpMenu.add_command(label="Help", underline=0,
> if not MAC:
> helpMenu.add_command(label="About", underline=0,
> self.menubar.add_cascade(label="Help", underline=0,
There's some magic in the Tk-Cocoa help menu--if you define the
tk::mac::showHelp command and map it to your function that calls user
help, you don't need to add a separate entry for help. (There's already
an entry hard-coded for help, along with the search field.) So the
helpMenu.add_Command(label="Help")... stuff is redundant.
> I end up with these menus:
> About ActivePython3.2 # correctly invokes my about action
If you're just running the app from Python and not wrapping it with a
tool such as py2app, this is the expected behavior. The "about" menu
picks up the name of the executable from its info.plist file, which in
this case is Python.
> Search # some apple-specific thing that just appears
> ActivePython3.2 Help # invokes my help action
> Help # invokes my help action
> (1) I don't know how to rename the "ActivePython3.2" menu to "My App".
> (2) I don't know how to rename the "About ActivePython3.2" menu option
> to "About" or "About My App".
See above--you need to wrap this as a standalone app using py2app or
> (3) I don't know how to eliminate the "ActivePython3.2 Help" menu option.
> If I don't do helpMenu.add_command() on the Mac that menu has no
> items ('cos the About is in the ActivePython3.2 menu) and so the
> Help menu doesn't appear at all.
If you don't add any items to the help menu but just define it, I would
expect to see an entry called "ActivePython 3.2 Help" that calls up a
dialog which says, "Help isn't available for ActivePython 3.2."
This is how I set up my help menu is one of my Python apps:
self.helpmenu = Menu(self.mb, name='_help')
self.helpmenu.add_command(label='Contact Code by Kevin',
Hope this helps,
Code by Kevin
More information about the Tkinter-discuss