Buttons have their own coordinate system according to the “grid_location” method?

邮差的信 提交于 2019-12-01 06:01:12
Bryan Oakley

You are correct that each button "has it's own coordinate system". More accurately, though, the event.x and event.y values are relative to the widget associated with the event rather than the widget's parent or the root window.

If you really do need the row and column that the widget is in you can use grid_info to get the row and column of the widget associated with the event. For example:

def mouse(event):
    grid_info = event.widget.grid_info()
    print("row:", grid_info["row"], "column:", grid_info["column"])
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!