- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
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
Deleting a Label in Python Tkinter
Tkinter label widgets are used to display text and images in the application. We can also configure the properties of Label widget that are created by default in a tkinter application.
If we want to delete a label that is defined in a tkinter application, then we have to use the destroy() method.
Example
In this example, we will create a Button that will allow the user to delete the label from the widget.
# Import the required libraries from tkinter import * from tkinter import ttk from PIL import Image, ImageTk # Create an instance of tkinter frame or window win = Tk() # Set the size of the window win.geometry("700x350") def on_click(): label.after(1000, label.destroy()) # Create a Label widget label = Label(win, text=" Deleting a Label in Python Tkinter", font=('Helvetica 15')) label.pack(pady=20) # Add a Button to Show/Hide Canvas Items ttk.Button(win, text="Delete", command=on_click).pack() win.mainloop()
Output
If we run the above code, it will display a window with a label widget and a Button.
Now, click the button to delete the Label from the window.
- Related Articles
- How to update a Python/tkinter label widget?
- How to justify text in label in tkinter in Python Need justify in tkinter?
- Python Tkinter – How do I change the text size in a label widget?
- Underline Text in Tkinter Label widget
- Update Tkinter Label from variable
- How to create a hyperlink with a Label in Tkinter?
- How to add Label width in Tkinter?
- How do you create a clickable Tkinter Label?
- How to get the Tkinter Label text?
- Changing Tkinter Label Text Dynamically using Label.configure()
- How to center a label in a frame of fixed size in Tkinter?
- How to change the color of a Tkinter label programmatically?
- How to update the image of a Tkinter Label widget?
- How to set the height/width of a Label widget in Tkinter?
- How to change the size of text on a label in Tkinter?

Advertisements