How to Create a Grid Layout? #2944
-
How to create a layout like this: `
` |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
At present, there isn't a native grid layout mechanism in Toga; See #2162 for the ticket tracking the feature request. In the meantime, the best option is to have a column box, each of which contains a series of row boxes where each widget at position N has either (a) a fixed width, or (b) a common In your example, you'd need to duplicate the This won't guarantee a grid - if any of the individual widgets exceed the minimum width allocation, the grid will start to be misalighned; but when there's sufficient space for an unconstrained layout, the grid should be aligned. |
Beta Was this translation helpful? Give feedback.
At present, there isn't a native grid layout mechanism in Toga; See #2162 for the ticket tracking the feature request.
In the meantime, the best option is to have a column box, each of which contains a series of row boxes where each widget at position N has either (a) a fixed width, or (b) a common
flex
value.In your example, you'd need to duplicate the
container_box
constructor so you're creating multiple ROW boxes (one for each row of the grid); you'd then add eitherwidth=N
(for some value of N - say, 100), orflex=1
toupperCase
andlowerCase
. If you want the grid to be sized so that the first column is twice the size of the second column, you'd setflex=2
onupperCase
, andflex=1
onl…