Starndard File Menu : Menu : Tkinker PYTHON TUTORIALS


PYTHON TUTORIALS » Tkinker » Menu »

 

Starndard File Menu


Starndard File Menu
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.configmenu = self.main_menu )

        fileMenu = Menu(self.main_menu)

        self.main_menu.add_cascadelabel="e", menu=fileMenu )

        fileMenu.add_commandlabel="w", command=self.NewFile )
        fileMenu.add_commandlabel="n", command=self.OpenFile )
        fileMenu.add_separator()
        fileMenu.add_commandlabel="t", command=self.Close )

        toolMenu = Menu(self.main_menu)
        self.main_menu.add_cascadelabel="s", menu=toolMenu )
        toolMenu.add_commandlabel="1", command=self.notdone )
        submenu = Menu(toolMenu)
        toolMenu.add_cascadelabel="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()



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Tkinker
» Menu