获取给定其项目句柄的Canvas小部件上项目的当前坐标? [英] Get the current coordinates of an item on a Canvas widget given its item handle?

查看:88
本文介绍了获取给定其项目句柄的Canvas小部件上项目的当前坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过阅读文档( http://effbot.org/tkinterbook/canvas.htm#reference ),在我看来没有办法做到这一点。只是想确保我没有记错。 (即,例如,如果要进行边界检查,则必须在程序中内部存储各个项目的坐标。[例如,在移动椭圆形之前,检查它不会撞到墙壁上,用一条线表示)当前画布,其坐标信息也已存储。])

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.])

推荐答案

使用坐标方法:

coords = the_canvas.coords(item_id)

这篇关于获取给定其项目句柄的Canvas小部件上项目的当前坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆