sum.day10

Yesterday basis of added:

menu: Menu Options

1, first create a main menu, a window into the root inside, tearoff = 0, prevent the smell menu

2, and then create a submenu, create a container placed just inside the main menu

3. Main Menu .add_cascade (label = 'label', menu = sub-menu), submenu added to the Main Menu

4. submenus .add_command (), to add the functionality submenu

import tkinter
root = tkinter.Tk()
root.geometry("500x500")
bigmenu = tkinter.Menu (the root) # Create main menu 
FileMenu = tkinter.Menu (bigmenu, tearoff = 0) # create submenus 
bigmenu.add_cascade (label = ' file ' , MENU = FileMenu) # will be added to the main menu, submenu 
= tkinter.Menu eitmenu (bigmenu, tearoff = 0) # create submenus 
bigmenu.add_cascade (label = " Save as " , the mENU = eitmenu) # will be added to the main menu submenu 
hatmenu = tkinter.Menu (bigmenu, tearoff = 0)
bigmenu.add_cascade (label = ' option ' , the MENU = FileMenu)
 # add options in the submenu 
filemenu.add_command (label = ' Open File ' )
filemenu.add_command (label = ' open file ' ) # submenu add functionality 
eitmenu.add_command (label = ' open file ' ) # submenu add functionality 
eitmenu.add_command (label = ' open file ' ) # submenu may be added function 
eitmenu.add_command (label = ' open file ' ) # submenu add functionality 
hatmenu.add_command (label = ' open file ' ) # submenu add functionality 
hatmenu.add_command (label = ' open file ' ) # submenu Add features
hatmenu.add_command (label = ' open file ' ) # submenu add functionality 
root.config (MENU = bigmenu)
root.mainloop ()

 

Guess you like

Origin www.cnblogs.com/Alom/p/11220819.html