WorkingRobot
WorkingRobot

Reputation: 424

How to remove all tags from Tk Text() object

I have a text object that has some tags in it. It isn't defined what the text is because it is editable. I am trying to remove all tags from that Text() object. The object is called text.

I tried using a for loop, but it isn't working the way I want it to. If it helps, I am using Python 3.2.

I also have a dictionary of what the tags are. Here is the link:

http://pastebin.com/MTwM0yrQ

Syntax:

'word/tagName':'color(don't mess with this)',...

Upvotes: 2

Views: 4614

Answers (1)

saulspatz
saulspatz

Reputation: 5281

Try this:

for tag in text.tag_names():
    text.tag_delete(tag)

I haven't actually tested this, but if I understand the docs correctly, it ought to work.

Upvotes: 3

Related Questions