How to get a widget position inside it's layout in Kivy?

拟墨画扇 提交于 2020-02-02 13:36:26

问题


I have a GridLayout and I added some Image widgets on it after adding of images I want to draw a rectangle in each image by using their canvas but I couldn't because I don't know the exact Image widgets positions on GridLayout.

In last line of my Python code : Rectangle(pos = (child.x - 2.4, child.y + 467), size = (70, 70))

How to draw this rectangle in child(My method is not good^),

Also Why my GridLayout not coming in center after setting it's pos_hint = {"center_x" : .5}?


回答1:


If I understand question right, try to use such methods as to_local(), to_parent(), to_widget() and to_window(). Also you could try to subtract position of your GridLayout from Widgets' positions.



来源:https://stackoverflow.com/questions/25356210/how-to-get-a-widget-position-inside-its-layout-in-kivy

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