tk.Text – Clear text contents

To clear the entire text in a text widget, use the .delete() method.

my_text_widget.delete("1.0", tk.END)

If the text widget is disabled, deleting the contents won't work. We would need to change the state to normal first.

1
2
3
4
5
6
# Enable the widget so we can delete its contents.
my_text_widget.configure(state="normal")
my_text_widget.delete("1.0", tk.END)

# Now we can change it back to disabled.
my_text_widget.configure(state="disabled")