>> master is a reference to a Tk() or Toplevel(). Frames do not contain >> menus, but the windows that contain them do. > > This is the main reason why I always rant about examples of Tkinter > programming creating windows by sub-classing Frame: frames are not > windows. If you want to create a window, sub-class Toplevel (or Tk), not > Frame. A frame is a general-purpose container. It can be sub-classed to > create new "mega-widgets" that can be used in any context. This is > obviously not the case in the code above, as the parent passed to any > instance of MenuDemo *must* be a Toplevel or Tk. So just write: > > class MenuDemo(Toplevel): > def __init__(self): > Toplevel.__init__(self) > ... > def makeMenuBar(self): > self.menubar = Menu(self) > self.config(menu=self.menubar) > ... > > and your life will be easier ;-) > > HTH > --python -c "print ''.join([chr(154 - ord(c)) for c in > 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
btw im tkinter newbie so this question could be stupid is it alright to use Menu instead Toplevel or Tk like this? from Tkinter import * from tkMessageBox import * class MenuDemo(Menu): def __init__(self, master=None): Menu.__init__(self, master) self.createWidgets() self.master.title('Toolbars and Mennus') self.master.iconname('tkpython') def createWidgets(self): self.makeMenuBar() self.makeToolBar() L = Label(self.master, text='Menu and Toolbar demo') L.config(relief=SUNKEN, width=40, height=10, bg='white') L.pack(expand=YES, fill=BOTH) -- http://mail.python.org/mailman/listinfo/python-list