what is wrong with this program?

Adonis adonisv at DELETETHISTEXTearthlink.net
Tue Aug 17 21:03:00 EDT 2004


"Ali" <alikakakhel3 at hotmail.com> wrote in message
news:8f17f4bc.0408171623.4f055fb3 at posting.google.com...
> 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()

---

Hope this helps.

Adonis





More information about the Python-list mailing list