Close Window In Tkinter
Tkinter is Used to create Graphical User Interface(GUI) in Python.It’s the only framework built into the Python standard library. This framework provides Python users with a simple way to create GUI elements using the widgets found in the Tk toolkit.
To close a tkinter window, You can use destroy() method. destroy() is a universal widget method That You Can use any of the Tkinter widget.
Now I am going to implement the destroy() method:
from tkinter import *
win = Tk()
win.title("This is Close Window Example")
win.geometry("800x350+450+86")
win.config(bg="#CDB7B5")
lbl = Label(win, text="IF Click Close Button, Window Will Be Closed",
font=("Times New Roman",27,"bold"),bg="#CDB7B5")
lbl.pack(pady=40)
btn = Button(win, text="Close Window",bg="#00FA9A", width=20, height=2,
font=("Times New Roman",20,"bold"),command=win.destroy)
btn.pack(pady=30)
win.mainloop()
Write Down Code Your Code Editor. To show Your Output. If Use Pycharm Press Shift+F10 and Show Your Output.
إرسال تعليق