How to Delete Tkinter Text Box's Contents

Tkinter Text widget has delete(first, last=None) method to delete the characters at the index of first, or within the range of (first, last) from the text box.

If last is not given, only the character specified in the first position is deleted.

Example Code to Clear The Content of Tkinter Text Widget

import tkinter as tk
root = tk.Tk()

def clearTextInput():

textExample=tk.Text(root, height=10)
btnRead=tk.Button(root, height=1, width=10, text="Clear", 


textExample.get("1.0", "end")

"1.0" and "end" refer to the first character and the last character of the contents in the Text widget, the same as introduced in the article of how to get the input of the Text widget.

Related Article - Tkinter Text

  • How to make Tkinter Text widget read only
  • How to Get the Input from Tkinter Text Box
  • How to Set Font of Tkinter Text Widget
  • How to Set Text of Tkinter Text Widget with A Button
  • comments powered by Disqus