Python 3 Tkinter Close Window on Button Click Press Event GUI Desktop App Full Project For Beginners

 

 

 

main.py

 

 

#Import the required libraries
from tkinter import *

#Create an instance of tkinter frame
win= Tk()

#Set the geometry of frame
win.geometry("600x250")

#Create a Label
Label(win, text="Press the Close Button to close the window",
font=('Helvetica bold', 11)).pack(pady=20)
#Define a function to close the window
def close_win():
   win.destroy()

#Create a Button for closing the window
button= Button(win, text="Close", command=close_win)
button.pack(pady=20)

win.mainloop()

Leave a Reply