close tkinter window code example

Example 1: how to manually close tkinter window

root = tk()
root.destroy()

Example 2: python tkinter close gui window

from tkinter import *
root=tk.Tk()
root.destroy()

Example 3: python tkinter how to close a window

root.destroy()

Example 4: close window tkinter

try:
    import Tkinter as tk
except:
    import tkinter as tk

root = tk.Tk()
root.geometry("100x50")

def close_window():
    root.destroy()

button = tk.Button(text = "Click and Quit", command = close_window)
button.pack()

root.mainloop()