closes all windowsbut its relative destroy erases just one window example - pp \gui\intro\gui py from tkinter import root tk(button(roottext='press'command=root quitpack(side=leftroot mainloop(this version produces the window in figure - because we didn' tell the button to expand into all available spaceit does not do so figure - button on the left in both of the last two examplespressing the button makes the gui program exit in older tkinter codeyou may sometimes see the string exit assigned to the command option to make the gui go away when pressed this exploits tool in the underlying tk library and is less pythonic than sys exit or root quit widget resizing revisitedexpansion even with gui this simplethere are many ways to lay out its appearance with tkinter' constraint-based pack geometry manager for exampleto center the button in its windowadd an expand=yes option to the button' pack method call in example - the line of changed code looks like thisbutton(roottext='press'command=root quitpack(side=leftexpand=yesthis makes the packer allocate all available space to the button but does not stretch the button to fill that space the result is the window captured in figure - figure - pack(side=leftexpand=yesif you want the button to be given all available space and to stretch to fill all of its assigned space horizontallyadd expand=yes and fill= keyword arguments to the pack call this will create the scene in figure - graphical user interfaces