Your observation is incorrect. If you configure a tag and then delete all text, the tag still exists. You are able to use the tag on additional text without having to recreate the tag.
If you manually insert text it won't automatically get the tag since tkinter has no way of knowing what tags to use. Tkinter will only add the tags that are on the character before and after the insertion point. Since there are no characters before or after the insertion point, the new text won't get any tags.
When you are manually editing the text widget, all text goes through the underlying insert
method. The documentation for the insert
message includes this:
If there is a single chars argument and no tagList, then the new text will receive any tags that are present on both the character before and the character after the insertion point; if a tag is present on only one of these characters then it will not be applied to the new text.
Note: when you press a key in the text widget, it calls the insert
method with no tagList. For example, pressing the "a" key on the keyboard results in insert("insert", "a")
(ie: there is no tagList argument)