开发者

can someone help me with tags in canvas?

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开发者_如何学C in canvas when using python.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜