Movatterモバイル変換


[0]ホーム

URL:


Open In App
Next Article:
Python Tkinter - Entry Widget
Next article icon

Prerequisite:Python GUI – tkinter

In this article, the Task is to remove the text from label, once text is initialized in Tkinter. Python offers multiple options for developing GUI (Graphical User Interface) out of which Tkinter is the most preferred means. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest, most reliable and easiest way to create a desired GUI application. 

The Task is to remove the text from label, once text is initialized in Tkinter.

Approach:

  • Import module
  • Create a normal Tkinter window.
  • Add Label and Create One Button

Syntax:

Text(Object Name,text="Enter Text", **attr)

  • For remove the text, we will useconfig() method in Tkinter

configis used to access an object's attributes after its initialization.

Syntax:

Object_Name.config(**attr)

Given below is the program to implement the same:

Python3
# Import Modulefromtkinterimport*# Create Objectroot=Tk()# specify size of window.root.geometry("400x400")# Remove text from labeldefremove_text():label.config(text="")# Create Labellabel=Label(root,text="Hello World!",font="BOLD")label.pack()# Create Delete ButtonButton(root,text="Delete",command=remove_text).pack()# Execute Tkinterroot.mainloop()

Output:

Output:before clicking delete
Output:after clicking delete

Improve
Article Tags :
Practice Tags :

Similar Reads

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood ourCookie Policy &Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences

[8]ページ先頭

©2009-2025 Movatter.jp