Josh Bloom
Josh Bloom

Reputation: 167

kivy gridlayout, stop dynamic resizing of children

I have a grid layout containing a variable amount of children. n1...n∞, I can never predict how many children the grid will contain.

Kivy, rather annoyingly makes the children smaller and smaller in relation to the amount of children in the grid. for example:

layout2 = GridLayout(cols=2, size_hint_y=(3))
    layout2.bind(minimum_height=layout2.setter('height'))

this size is fine when the grid contains around 6 children, however when it contains say 20, the images are tiny.

How can I stop kivy resizing?

Answers in Python please.

Upvotes: 1

Views: 683

Answers (2)

Yoav Glazner
Yoav Glazner

Reputation: 8041

You may want to make size_hint_y depend on the row count, So it may look like this in a KV file

ScrollView:
    MyGrid:
        size_hint_y: self.rows / 10.0 + 1.0 #you should play with this a bit ...

Upvotes: 1

el3ien
el3ien

Reputation: 5415

Try size_hint=None

layout2 = GridLayout(cols=2, size_hint_y=None)

Upvotes: 0

Related Questions