tags:

views:

19

answers:

1

i tried to figure out what tags were in canvas however i am having a hard time understanding it. can someone explain what tags do and how to use them in canvas when using python.

A: 

Every object in a canvas has an id. You can reference that object by that id to delete it, modify it, move it, etc.

Objects can also have one or more tags. A tag can be associated with a single object, in which case it is just another name for that object. For example, if you draw a red rectangle and a blue rectangle, you can give the first one the tag "red_rect" and the second "blue_rect". Then, anywhere you might need the id you could instead use the tag.

One tag can be associated with more than a single item. So, for example, in addition to the "red_rect" and "blue_rect" tags, you could also give each item a "rect" tag. Then, when you use "rect" where you might use an id (such as to move the object), this will affect all objects with the tag. In this way you can move, configure or delete whole groups of items at a time.

You can use tags to implement such common features as letting the user name objects that they draw interactively, or to logically group multiple objects into a single composite object.

Bryan Oakley