टिंकर शुरू में एक विंडो या फ्रेम बनाता है जिसमें विजेट और लेबल होते हैं। मान लीजिए कि हम एक बटन के साथ टिंकर विंडो को बंद करना चाहते हैं। एक बटन एक यूआई विजेट है जिसका उपयोग एक निश्चित ऑपरेशन करने के लिए किया जा सकता है।
उदाहरण
यहां, हम एक बटन बनाएंगे जो टिंकर विंडो को बंद कर देगा। टीसीएल दुभाषिया को बंद करने और समाप्त करने के लिए, हम मुख्य रूप से नष्ट () . का उपयोग करते हैं विधि।
#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() आउटपुट
उपरोक्त कोड को चलाने से एक विंडो प्रदर्शित होगी जिसमें एक बटन होगा जिसे विंडो या फ्रेम को बंद करने के लिए ट्रिगर किया जा सकता है।

अब विंडो बंद करने के लिए "बंद करें" बटन पर क्लिक करें।