Reputation:
Is there a way to remove all of the tags on a text widget in tkinter?
text.tag_config("NONE",font=Font(family="Arial",size=10))
text.add_tag("NONE","1.0","end")
does not work. If I make part of the text colored red and try to remove that tag, nothing happens. The only way I can clear the tag (as a user) is to delete the text that was tagged with red.
Upvotes: 1
Views: 1949
Reputation: 386362
To remove any single tag, use tag_remove
, giving it the tag name. To remove from the entire document use the index "1.0" and "end"
text.tag_remove("the_tag", "1.0", "end")
To remove all tags, iterate over a list of all tags. You can get a list of all the tags with tag_names()
. The list will include all of your custom tags along with the tag "sel" which is used to manage the selection.
for tag in text.tag_names():
text.tag_remove(tag, "1.0", "end")
Upvotes: 4