कभी-कभी, हम एक ऐसे विजेट को हटाना चाहते हैं जो एप्लिकेशन में किसी काम का नहीं है। हम .नष्ट . का उपयोग करके विंडो या फ़्रेम से विजेट हटा सकते हैं टिंकर में विधि। इसके लिए एक फ़ंक्शन को परिभाषित करके इसे विजेट में लागू किया जा सकता है।
उदाहरण
इस उदाहरण में, हमने एक बटन बनाया है जो विंडो से टेक्स्ट लेबल विजेट को हटा देगा।
#Import the tkinter library
from tkinter import *
#Create an instance of tkinter frame
win = Tk()
#Set the geometry
win.geometry("650x450")
#Define a function to remove the text from the screen
def delete_text():
text.destroy()
#Create a text widget
text= Label(win,text="This is a New Line", font=('Aerial bold', 20))
text.pack(pady=20)
#Create a button for Deleting Widget
Button(win, text= "Click Here", font=('bold',20), command=
delete_text).pack(pady=10)
win.mainloop() आउटपुट
उपरोक्त कोड को चलाने से निम्न आउटपुट उत्पन्न होगा -

अब, "यहां क्लिक करें" बटन पर क्लिक करें। यह विंडो से लेबल टेक्स्ट विजेट को हटा देगा।
