How To Clear Text In Python
How to clear the contents of a Tkinter Text widget?
Tkinter Text Widget is used to add the text writer in an application. It has many attributes and properties which are used to extend the functionality of a text editor. In order to delete the input content, we can use the delete("start", "end") method.
Example
#Import the tkinter library from tkinter import * #Create an instance of tkinter frame win = Tk() #Set the geometry win.geometry("600x250") #Define a function to clear the input text def clearToTextInput(): my_text.delete("1.0","end") #Create a text widget my_text=Text(win, height=10) my_text.pack() #Create a Button btn=Button(win,height=1,width=10, text="Clear",command=clearToTextInput) btn.pack() #Display the window without pressing key win.mainloop() Output
Running the above code will create a text widget and a button that can be used to clear the Input text.
Now Click on the "Clear" button, it will clear the input text.
Published on 26-Mar-2021 11:07:42
- Related Questions & Answers
- Get contents of a Tkinter Entry widget
- How to clear Text widget content while clicking on the Entry widget itself in Tkinter?
- How to highlight text in a tkinter Text widget?
- How to get the current length of the Text in a Tkinter Text widget?
- Get the text of a button widget in Tkinter
- How do I center the text in a Tkinter Text widget?
- How to highlight the current line of a Text widget in Tkinter?
- How to make the Tkinter text widget read only?
- How to erase everything from the Tkinter text widget?
- How to clear the Entry widget after a button is pressed in Tkinter?
- How to erase everything from a Tkinter text widget?
- How to create hyperlink in a Tkinter Text widget?
- How to get the input from the Tkinter Text Widget?
- How to change the color of certain words in a Tkinter text widget?
- Add advanced features to a tkinter Text widget
How To Clear Text In Python
Source: https://www.tutorialspoint.com/how-to-clear-the-contents-of-a-tkinter-text-widget
Posted by: lopezcoluseld87.blogspot.com

0 Response to "How To Clear Text In Python"
Post a Comment