Tkinter is a Python library that is used for creating and developing GUI-based applications. In this article, we will see how to remove text from a Label that will have some text in it.
To remove text from a label, we will create an associated button that will act as a trigger for the Label.
Example
#import Tkinter Library from tkinter import * #Create an instance of tkinter frame win= Tk() #Define the size and geometry of the frame win.geometry("700x400") #Create a function for the Button Comman def remove_text(): text.config(text=" ") #Create a text Label text= Label(win, text= "www.tutorialspoint.com", font= ("Poppins", 30)) text.pack(pady=20) #Create a Button my_button= Button(win, text= "Remove Text", command= remove_text) my_button.pack(pady=10) win.mainloop()
Output
Running the above code will create a button that can be used to remove the text from a label.
Now, click the “Remove Text” button. It will remove the text from the label and we will get the following screen.