Python (Tkinter) created menu wont show up -
i'm trying make top level file menu tkinter , not showing up. dont think need pack() since in master
from tkinter import * class mazeapp(object): def __init__(self, master=none): master.minsize(300, 300) self.makemenu(master) def makemenu(self, master): menubar = menu(master) filemenu = menu(menubar, tearoff=0) filemenu.add_command(label="open", command=self.test) filemenu.add_command(label="save", command=self.test) filemenu.add_separator() filemenu.add_command(label="exit", command=self.test) menubar.add_cascade(label="file", menu=filemenu) def onexit(self): master.destroy() def test(self): pass def main(): root = tk() app = mazeapp(root) root.mainloop() if __name__ == '__main__': main()
all shows 300*300 windows menu default one. ideas on i've gone wrong?
you need inform root widget you're assigning menubar. include line after you've created menubar:
master.config(menu=menubar)
Comments
Post a Comment