简体   繁体   中英

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

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} ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM