what is wrong with this program?

A

Ali

The following program is supposed to show a menu but it isnt showing
the drop down menus. It only shows the File and Help thing.

from Tkinter import *

def callback:
print "Alhumdulillah

root = Tk()

#create menu

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

filemenu = 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 me fix it
 
G

Greg Krohn

Ali said:
The following program is supposed to show a menu but it isnt showing
the drop down menus. It only shows the File and Help thing.

The code you posted doesn't even run. Copy and paste the *exact code*
that you used, and maybe we can help.


Greg
 
A

Adonis

Ali said:
The following program is supposed to show a menu but it isnt showing
the drop down menus. It only shows the File and Help thing.

from Tkinter import *

def callback:
print "Alhumdulillah

root = Tk()

#create menu

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

filemenu = 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 me fix it

Here is a working version, just compare to above should be quite
self explanitory, more help can be found on www.pythonware.com

---

from Tkinter import *

def callback():
print "Alhumdulillah"

root = Tk()

#create menu

m = Menu(root)

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

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

root.config(menu=m)
root.mainloop()
 

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

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top