grid-size style sets the number of columns and rows in a grid layout.
The number of rows can be left unspecified and it will be computed automatically.
This style only affects widgets with
grid-size style takes one or two non-negative
The first defines how many columns there are in the grid.
If present, the second one sets the number of rows – regardless of the number of children of the grid –, otherwise the number of rows is computed automatically.
Columns and rows¶
In the first example, we create a grid with 2 columns and 5 rows, although we do not have enough labels to fill in the whole grid:
In the second example, we create a grid with 2 columns and however many rows are needed to display all of the grid children:
To programmatically change the grid size, the number of rows and columns must be specified separately: