Each item can also have a tag (or more than one tag) associated with
it. We have seen tags used before in the Text widget, where sections
of text could be assigned a tag. A tag can be assigned when the item
is created, or you can use the
addtag method to
assign a tag after the item has been created.
There are two special tags that are assigned and maintained
"all" tag refers to
all the items in the Canvas. The
refers to the topmost item that the mouse cursor is over. If the
mouse cursor is outside the Canvas widget or not over an item, the
"current" tag does not exist.
You can use tags to
make changes to many different items at once. For instance, if you
want all circles to have the same color, but you want to be able to
change it from time to time, give all circles a
"circle" tag when you create them, using the
itemconfigure method to change the configuration
options of the items with the
Tags can also be logical expressions by
using the operators:
and parenthetical subexpressions. For example:
will find only those items with either
b tags, but not both.
The following are some sample syntax lines for creating tags:
"newtag" tag is added to the item that is above
tag/id item. If there is more than one
tag/id, the last item found will ...