1#
2# A simple grid
3#
4
5col_dsc = [70, 70, 70, lv.GRID_TEMPLATE.LAST]
6row_dsc = [50, 50, 50, lv.GRID_TEMPLATE.LAST]
7
8# Create a container with grid
9cont = lv.obj(lv.scr_act())
10cont.set_style_grid_column_dsc_array(col_dsc, 0)
11cont.set_style_grid_row_dsc_array(row_dsc, 0)
12cont.set_size(300, 220)
13cont.center()
14cont.set_layout(lv.LAYOUT_GRID.value)
15
16for i in range(9):
17    col = i % 3
18    row = i // 3
19
20    obj = lv.btn(cont)
21    # Stretch the cell horizontally and vertically too
22    # Set span to 1 to make the cell 1 column/row sized
23    obj.set_grid_cell(lv.GRID_ALIGN.STRETCH, col, 1,
24                      lv.GRID_ALIGN.STRETCH, row, 1)
25
26    label = lv.label(obj)
27    label.set_text("c" +str(col) +  "r" +str(row))
28    label.center()
29
30