3 popup windows with menus : Menu « GUI Tk « Python






3 popup windows with menus

3 popup windows with menus

from Tkinter import *



def notdone():  
    showerror('Not implemented', 'Not yet available') 

def makemenu(win):
    top = Menu(win)             
    win.config(menu=top)        
    
    file = Menu(top)
    file.add_command(label='New...',  command=notdone,  underline=0)
    file.add_command(label='Open...', command=notdone,  underline=0)
    file.add_command(label='Quit',    command=win.quit, underline=0)
    top.add_cascade(label='File',     menu=file,        underline=0)

    edit = Menu(top, tearoff=0)
    edit.add_command(label='Cut',     command=notdone,  underline=0)
    edit.add_command(label='Paste',   command=notdone,  underline=0)
    edit.add_separator()
    top.add_cascade(label='Edit',     menu=edit,        underline=0)

    submenu = Menu(edit, tearoff=0)
    submenu.add_command(label='Spam', command=win.quit, underline=0)
    submenu.add_command(label='Eggs', command=notdone,  underline=0)
    edit.add_cascade(label='Stuff',   menu=submenu,     underline=0)


root = Tk()
for i in range(3):              
    win = Toplevel(root)
    makemenu(win)
    Label(win, bg='black', height=5, width=15).pack(expand=YES, fill=BOTH)
Button(root, text="Bye", command=root.quit).pack()
root.mainloop()


           
       








Related examples in the same category

1.A big menu bar
2.Set up menu and add action to it
3.Disable a menu itemDisable a menu item
4.Set menu item font
5.Menu item mouse on (active) foreground colorMenu item mouse on (active) foreground color
6.Underline for menu item textUnderline for menu item text
7.Menu separatorMenu separator
8.Cascade MenuCascade Menu
9.Disable a menuDisable a menu
10.Creating a small menuCreating a small menu
11.Menu separator 2 and menu action
12.Menu actionMenu action
13.Add menu to a windowAdd menu to a window
14.A Simple Form with Menu
15.Three Menu inside a formThree Menu inside a form
16.Framework for a single document interfaceFramework for a single document interface
17.Menu/tool bars packed before middleMenu/tool bars packed before middle