- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between root.destroy() and root.quit() in Tkinter(Python)?
When we invoke the destroy() method with the tkinter window object, it terminates the mainloop process and destroys all the widgets inside the window. Tkinter destroy() method is mainly used to kill and terminate the interpreter running in the background.
However, quit() method can be invoked in order to stop the process after the mainloop() function. We can demonstrate the functionalities of both methods by creating a button Object.
#Import the required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the geometry of frame win.geometry("650x450") #Define a function for Button Object def quit_win(): win.quit() def destroy_win(): win.destroy() #Button for Quit Method Button(win,text="Quit", command=quit_win, font=('Helvetica bold',20)).pack(pady=5) #Button for Destroy Method Button(win, text= "Destroy", command=destroy_win, font=('Helvetica bold',20)).pack(pady=5) win.mainloop()
Running the code will display a window with two buttons “Quit” and “Destroy” respectively.
Warning − quit() will terminate the application abruptly, hence it is recommended that you close the application from the manager after execution.
- What is the root class in Java?
- How can I resize the root window in Tkinter?
- destroy() method in Tkinter - Python
- How do I get rid of the Python Tkinter root window?
- What is the difference between the widgets of tkinter and tkinter.ttk in Python?
- What is the difference between focus and focus_set methods in Tkinter?
- Difference between tkinter and Tkinter
- Guess Nearest Square Root in Python
- C++ Program to count square root cube root and both in given range
- Square and Square root in Arduino
- What is the difference between a variable and StringVar() of Tkinter?
- jQuery :root Selector
- Python Tkinter – How to position a topLevel() widget relative to the root window?
- What is the difference between = and == operators in Python?
- Sum Root to Leaf Numbers in Python