简体   繁体   English

如何在Tkinter中从其唯一ID获取对象?

[英]How can I get object from its unique id in Tkinter?

canvas=Canvas(...)
unique_id=canvas.create_rectangle(...)
unique_id.tag_bind(...)

I get this error because it is an integer 我收到此错误,因为它是整数

AttributeError: 'int' object has no attribute 'tag_bind'

I need to get the object 我需要拿东西

You need to use tag_bind in the following with with canvas items. 您需要将以下tag_bind与画布项目一起使用。

canvas=Canvas(...)
unique_id=canvas.create_rectangle(...)
canvas.tag_bind(unique_id,...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM