[Tkinter-discuss] problem with menus, Tkinter on macpython

Kevin Walzer kw at codebykevin.com
Mon Apr 26 16:18:58 CEST 2010


On 4/23/10 1:23 PM, Joe Barfett wrote:
> Hello again,
> The last time I updated, I think my code was scrambled. I am still
> having the same problem in that I cannot make a menu appear using
> Tkinter on macpython. The exact same code works very well on my PC.

>
> I'm using windows XP and python version 2.5 with Tkinter. A menu
> appears. The exact same code on OSX 10.5 and 10.5 in macpython will
> display a frame but no menu.
> Can anyone help?
> Thanks very much!
> joe
>

Try this:

from Tkinter import *
root = Tk()
def hello():
     print "hello!"
# create a toplevel menu
menubar = Menu(root)
root.config(menu=menubar)
hellomenu=Menu(menubar)
menubar.add_cascade(label="Hello", menu=hellomenu)
hellomenu.add_command(label="Hello!", command=hello)
# display the menu
root.config(menu=menubar)
mainloop()

It adds a "hello" submenu that's visible on the Mac. I'm not sure why 
the other code works on Windows, but this should work too.

--Kevin

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com


More information about the Tkinter-discuss mailing list