[Tutor] Creating Tkinter Menubars
Double Six
doublesix at ureach.com
Tue Nov 15 22:17:53 CET 2005
Hi,
I am testing the following Tkinter code (attached at the end of
this message) by Fredrik Lundh on a Mac OS X 10.4.2 with Python
version 2.3. I do get a root window, but it is totally blank
without the desirable menubars such as File and Edit. What am I
missing?
Any help will be highly appreciated.
Thanks,
Joe
=========
from Tkinter import *
class AppUI(Frame):
def __init__(self, master=None):
Frame.__init__(self, master, relief=SUNKEN, bd=2)
self.menubar = Menu(self)
menu = Menu(self.menubar, tearoff=0)
self.menubar.add_cascade(label="File", menu=menu)
menu.add_command(label="New")
menu = Menu(self.menubar, tearoff=0)
self.menubar.add_cascade(label="Edit", menu=menu)
menu.add_command(label="Cut")
menu.add_command(label="Copy")
menu.add_command(label="Paste")
try:
self.master.config(menu=self.menubar)
except AttributeError:
# master is a toplevel window (Python 1.4/Tkinter
1.63)
self.master.tk.call(master, "config", "-menu",
self.menubar)
self.canvas = Canvas(self, bg="white", width=400,
height=400,
bd=0, highlightthickness=0)
self.canvas.pack()
root = Tk()
app = AppUI(root)
app.pack()
root.mainloop()
________________________________________________
Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag
More information about the Tutor
mailing list