How to Delete Tkinter Text Box's Contents?

Tkinter provides many functions and modules through which we can create fully featured applications with buttons, dialogue boxes, widgets, and many more.

To create a text widget, we can use the tkinter entry widget function which is basically a constructor and it takes the window or frame of the tkinter. Further, we can delete the content of this text widget using the built-in method delete(first, last=None) which basically takes a range within the textbox.

In this example, we will create a Delete Button which basically deletes all the contents from the given text box.


from tkinter import *

win= Tk()

label= Label(win, text= "Write something ??", font= ('Helvetica', 25))

#Create a Text Widget
text= Text(win, height=10)

def delete():

#Create a Delete Button to remove the Text from the text-widget

b1= Button(win, text= "Delete",command= delete)


Running the above code will create a text widget and a delete button which can be used to delete the contents written in the text box.

Type something inside the textbox, and then, click the “Delete” button. It will erase the content inside the textbox.