from Tkinter import *class MenuTest : def NewFile(self) : print "Creating a new file.." def OpenFile(self) : print "Opening an existing file..." def Close(self) : self.root.destroy() def notdone(self) : print "Not done yet!!" def __init__(self) : self.root = Tk() self.main_menu = Menu(self.root) self.root.config( menu = self.main_menu ) fileMenu = Menu(self.main_menu) self.main_menu.add_cascade( label="e", menu=fileMenu ) fileMenu.add_command( label="w", command=self.NewFile ) fileMenu.add_command( label="n", command=self.OpenFile ) fileMenu.add_separator() fileMenu.add_command( label="t", command=self.Close ) toolMenu = Menu(self.main_menu) self.main_menu.add_cascade( label="s", menu=toolMenu ) toolMenu.add_command( label="1", command=self.notdone ) submenu = Menu(toolMenu) toolMenu.add_cascade( label="s", menu=submenu) submenu.add_command(label="Other 1", command=self.notdone) submenu.add_command(label="Other 2", command=self.notdone) self.root.mainloop()mt = MenuTest()
Name (required)
email (will not be published) (required)
Website