win toplevel(make new window label(wintext='hard drive reformatted!'pack(add few widgets button(wintext='ok'command=win destroypack(set destroy callback if makemodalwin focus_set(take over input focuswin grab_set(disable other windows while ' openwin wait_window(and wait here until win destroyed print('dialog exit'else returns right away root tk(button(roottext='popup'command=dialogpack(root mainloop(this script is set up to create pop-up dialog window in either modal or nonmodal modedepending on its makemodal global variable if it is run with no command-line argumentsit picks nonmodal stylecaptured in figure - figure - nonmodal custom dialogs at work the window in the upper right is the root window herepressing its "popupbutton creates new pop-up dialog window because dialogs are nonmodal in this modethe root window remains active after dialog is popped up in factnonmodal dialogs never block other windowsso you can keep pressing the root' button to generate as many copies of the pop-up window as will fit on your screen any or all of the pop ups can be killed by pressing their ok buttonswithout killing other windows in this display making custom dialogs modal nowwhen the script is run with command-line argument ( python dlg-custom py )it makes its pop ups modal instead because modal dialogs grab all of the interface' attentionthe main window becomes inactive in this mode until the pop up is killedyou can' even click on it to reactivate it while the dialog is tkinter tourpart