如何获取小部件的当前 x 和 y 坐标? [英] How to get the widget's current x and y coordinates?

查看:62
本文介绍了如何获取小部件的当前 x 和 y 坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在为4 in a row"编写游戏项目.为了制作图片widget磁盘落在列中的动画,我一直在考虑创建一个while循环:

I'm currently writing a game project as for the game "4 in a row". To make the animation where the picture widget disk falls in the column, I've been thinking about creating a while loop for as in:

while widgetx != __ and widgety != __

在空白部分将有我需要获取的值.

where at the blank parts there will be the values I'll need to get.

我的问题是是否有一个函数可以返回小部件的当前 xy 值.

My question is if there's a function that returns the current x and y value for a widget.

推荐答案

winfo_rootx()winfo_rooty() 返回相对于屏幕左上角的坐标.winfo_xwinfo_y 返回窗口相对于其父窗口的坐标.

winfo_rootx() and winfo_rooty() return the coordinates relative to the screen's upper left corner. winfo_x and winfo_y return the coordinates of a window relative to its parent.

这篇关于如何获取小部件的当前 x 和 y 坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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