How to Add a Widget to a Layout in a position fixed to its size?

11 views
Skip to first unread message

GreyGnome

unread,
Oct 21, 2016, 8:43:51 AM10/21/16
to Kivy users support
 would like to add a Widget to a fixed position in a Float or RelativeLayout. The position needs to be 10 pixels from its left border, and 10 pixels down from its top border. The layout's size and position can change.

I don't want to use a pos_hint because that moves my widget as the layout is resized. It looks a little weird. That said, I can't seem to make it work the way I want..The problem, of course, is that I can't set a fixed position right away because I don't know how big the Layout is until after it's added.

I have tried to set it and then bind:
    self.bind(on_position=self.reposition_stuff, on_size=self.reposition_stuff)

But my self.reposition_stuff method is never called.

Am I on the right track, at least? Do layouts swallow the on_position and on_size events?

Thanks.

GreyGnome

unread,
Oct 22, 2016, 5:38:47 PM10/22/16
to Kivy users support
Got it. I needed to do:
self.bind(size=self.reposition_stuff)

Then I can have reposition stuff set the pos of the Widget, easy peasy.
Reply all
Reply to author
Forward
0 new messages