- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- 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 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
- What is the difference between a variable and StringVar() of Tkinter?
- What's the difference between "update" and "update_idletasks" in Tkinter?
- What is the difference between = and == operators in Python?
- What is the difference between the != and operators in Python?
- What is the difference between os.open and os.fdopen in python?
- What is the difference between dict.items() and dict.iteritems() in Python?
- What is the difference between __str__ and __repr__ in Python?
- What is the difference between attributes and properties in python?
- What is the difference between arguments and parameters in Python?
- What is the difference between single and double quotes in python?
- What is the difference between global and local variables in Python?
- Difference between import tkinter as tk and from tkinter import