问题
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