import sys from tkinter import toplevelbuttonlabel win toplevel(win toplevel(two independent windows but part of same process button(win text='spam'command=sys exitpack(button(win text='spam'command=sys exitpack(label(text='popups'pack(win mainloop(on default tk(root window the toplevel script gets root window by default (that' what the label is attached tosince it doesn' specify real parent)but it also creates two standalone toplevel windows that appear and function independently of the root windowas seen in figure - figure - two toplevel windows and root window the two toplevel windows on the right are full-fledged windowsthey can be independently iconifiedmaximizedand so on toplevels are typically used to implement multiple-window displays and pop-up modal and nonmodal dialogs (more on dialogs in the next sectionthey stay up until they are explicitly destroyed or until the application that created them exits in factas coded herepressing the in the upper right corner of either of the toplevel windows kills that window only on the other handthe entire program and all it remaining windows are closed if you press either of the created buttons or the main window' (more on shutdown protocols in momentit' important to know that although toplevels are independently active windowsthey are not separate processesif your program exitsall of its windows are erasedincluding all toplevel windows it may have created we'll learn how to work around this rule later by launching independent gui programs tkinter tourpart