Absolute positioning of labels

437 views
Skip to first unread message

hci...@gmail.com

unread,
Aug 19, 2013, 7:09:27 PM8/19/13
to kivy-...@googlegroups.com
I am ripping my hair out trying to get labels to position according to exact x,y positioning. I have a screen widget that I have added a button to and have set the button to an exact position and size. I then try to add two labels on top of this button (No I'm not using the button's text and I have good reason). I have tried to set the labels to be relative to the button, i.e. label.pos = button.pos which works if I add the labels to the canvas (Of course for obvious reason this is not a good idea), but if I add the label to the root widget the labels are nowhere near the button. What I see is that the button's position starts at the lower-left corner of the screen when I set it's x,y 0,0, but if I do the same for the labels kivy considers 0,0 to be the center of the screen. So if I try to position them at say 100,150 kivy puts it at center_x + 100, center_y + 150. I know the obvious thing would be to add all my widgets to a FloatLayout, but when I do that no sizing or positioning works on the button and the same issues happen on the labels as when they're added to the root widget. It seems no matter what I do I can't choose where to put labels. Any ideas?   

ZenCODE

unread,
Aug 20, 2013, 5:41:07 AM8/20/13
to kivy-...@googlegroups.com
Hi

It's difficult to say without seeing your code. Using the FloatLayout as the direct parent of your widgets should work though. Try setting the "pos_hint_x" to None and "pos_hint_y" to None, and the size_hint to (None, None)?

Otherwise, post you code here so we can have a look.

Peace

hci...@gmail.com

unread,
Aug 20, 2013, 11:31:39 AM8/20/13
to kivy-...@googlegroups.com
Lol!! I lost an entire day trying to fix that and it turned out to be that small little detail! Thanks man! 

ZenCODE

unread,
Aug 20, 2013, 4:08:15 PM8/20/13
to kivy-...@googlegroups.com
:-) Once too me almost two days of debugging to discover a comma should have been a point...
Reply all
Reply to author
Forward
0 new messages