Get the current coordinates of an item on a Canvas widget given its item handle?

醉酒当歌 提交于 2019-12-06 10:21:38

问题


From reading the docs (http://effbot.org/tkinterbook/canvas.htm#reference), there doesn't appear to me to be a way to do this. Just wanted to make sure I hadn't made a mistake. (I.e. one would have to internally store the coordinates of various items in a program if one wanted to do boundary checking, for example. [e.g. Check, before moving an oval, that it will not bump into a wall, represented by a line on the current canvas, the coordinate information of which is also stored.])


回答1:


Use the coords method:

coords = the_canvas.coords(item_id)


来源:https://stackoverflow.com/questions/28389728/get-the-current-coordinates-of-an-item-on-a-canvas-widget-given-its-item-handle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!