There are lots of ways to change both the appearance and functionality of the items in a text widget. For text, you can change the font, size, and color. Also, you can make text, widgets, or embedded images respond to keyboard or mouse actions.
To control these appearance and functional features, you associate each feature with a tag. You can then associate a tag with any number of pieces of text in the widget.
The name of a tag can be any string that does not contain white space or periods.
There is one special predefined tag called
SEL. This is the region currently selected,
Since any character may be part of more than one tag, there is a tag stack that orders all the tags. Entries are added at the end of the tag list, and later entries have priority over earlier entries.
So, for example, if there is a character
c that is part of two
is deeper in the tag stack than
wants the text to be green and
wants it to be blue,
will be rendered in blue because
has precedence over
You can change the ordering of tags in the tag stack.
Tags are created by using the
method on the text widget. See Section 24.8, “Methods on
Text widgets”, below, for information on this
and related methods.