कभी-कभी, Tkinter एप्लिकेशन test करते समय, हमें Tkinter default window या frame को hide करने की आवश्यकता हो सकती है। हमारे Tkinter window को या तो hide करने या destroy करने के दो general methods हैं।
mainloop() Tkinter window को तब तक चलाता रहता है जब तक इसे external events द्वारा close नहीं किया जाता। Window को destroy करने के लिए हम destroy() callable method का उपयोग कर सकते हैं।
हालांकि, Tkinter window को hide करने के लिए, हम generally "withdraw" method का उपयोग करते हैं जिसे root window या main window पर invoke किया जा सकता है।
इस उदाहरण में, हमने एक text widget और एक button "Quit" बनाया है जो root window को immediately close कर देगा। हालांकि, हम screen पर display होने से बचने के लिए withdraw method का भी उपयोग कर सकते हैं।
उदाहरण
# Import the library
from tkinter import *
# Create an instance of window
win = Tk()
# Set the geometry of the window
win.geometry("700x400")
def disable_button():
win.destroy()
# Create a Label
Label(win, text="Type Something", font=('Helvetica bold', 25), fg="green").pack(pady=20)
# Create a Text widget
text = Text(win, height=10, width=40)
text.pack()
# Create a Disable Button
Button(win, text="Quit", command=disable_button, fg="white", bg="black", width=20).pack(pady=20)
# win.withdraw()
win.mainloop()
उपरोक्त python code withdraw method का उपयोग करके root window को hide करता है। हालांकि, window को destroy करने के लिए, हम destroy method का उपयोग कर सकते हैं।
आउटपुट

जब आप Quit button पर क्लिक करते हैं, तो यह root window को hide कर देगा।