Popup three new window, with style : Toplevel « Tkinker « Python Tutorial






from Tkinter import *
root = Tk()                                                     
     
trees = [('The Larch!',          'light blue'),
         ('The Pine!',           'light green'),
         ('The Giant Redwood!',  'red')]
     
for (tree, color) in trees:
    win = Toplevel(root)                                        
    win.title('Sing...')                                        
    win.protocol('WM_DELETE_WINDOW', lambda:0)                  
    win.iconbitmap('py-blue-trans-out.ico')                     
     
    msg = Button(win, text=tree, command=win.destroy)           
    msg.pack(expand=YES, fill=BOTH)
    msg.config(padx=10, pady=10, bd=10, relief=RAISED)
    msg.config(bg='black', fg=color, font=('times', 30, 'bold italic'))
     
root.title('Lumberjack demo')
Label(root, text='Main window', width=30).pack()
Button(root, text='Quit All', command=root.quit).pack()         
root.mainloop()








18.31.Toplevel
18.31.1.Two top level windowsTwo top level windows
18.31.2.No default rootNo default root
18.31.3.Popup three new window, with style