close

How to clear/delete the contents of a Tkinter Text widget?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to clear/delete the contents of a Tkinter Text widget in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to clear/delete the contents of a Tkinter Text widget?

  1. How to clear/delete the contents of a Tkinter Text widget?

    I checked on my side by just adding '1.0' and it start working
    tex.delete('1.0', END)
    you can also try this

  2. clear/delete the contents of a Tkinter Text widget

    I checked on my side by just adding '1.0' and it start working
    tex.delete('1.0', END)
    you can also try this

Method 1

I checked on my side by just adding ‘1.0’ and it start working

tex.delete('1.0', END)

you can also try this

Method 2

According to the tkinterbook the code to clear a text element should be:

text.delete(1.0,END)

This worked for me. 

It’s different from clearing an entry element, which is done like this:

entry.delete(0,END) #note the 0 instead of 1.0

Conclusion

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read