what wrong with this program?

A

Ali

The following program is supposed to display a dropdown menu, however,
it only shows the File and Help things.

from Tkinter import *

root = Tk()

#create menu
m = Menu(root)
root.config(menu=m)

filemenu = Menu(m)
m.add_cascade(label="File", menu="filemenu")
filemenu.add_command(label="New", command=callback)
filemenu.add_separator()
filemenu.add_command(label="Quit", command=callback)

helpmenu = Menu(m)
m.add_cascade(label="Help", menu="helpmenu")
helpmenu.add_command(label="About...", command=callback)

root.mainloop()

please help fix this program.
 
R

Robert Kern

Ali said:
The following program is supposed to display a dropdown menu, however,
it only shows the File and Help things.

from Tkinter import *

root = Tk()

#create menu
m = Menu(root)
root.config(menu=m)

filemenu = Menu(m)
m.add_cascade(label="File", menu="filemenu")

The menu= argument needs to be the object itself, not a string.

See, e.g.

http://www.pythonware.com/library/tkinter/introduction/x5819-patterns.htm

--
Robert Kern
(e-mail address removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top