How to Clear Text From a Text Widget on Click in Tkinter
In this tutorial, we are going to see how to clear text from a Text widget on click in Tkinter. The Text widget owns the delete(first, last=None) method to delete the characters in the range (first, last) of the Text widget.

How to Clear Text From a Text Widget on Click in Tkinter
In the following example “1.0” and “end” indicate the first character and the last character of the Text widget’s content.
import tkinter as tk def clear(): texte.delete("1.0","end") gui = tk.Tk() gui.geometry("300x150") texte = tk.Text(gui, height=5) texte.pack(pady=10) btn = tk.Button(gui, text="Clear", command=clear) btn.pack() gui.mainloop()
Output:
