acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

lv_example_grid_3.py (908B)

      1 #
      2 # Demonstrate grid's "free unit"
      3 #
      4 
      5 # Column 1: fix width 60 px
      6 # Column 2: 1 unit from the remaining free space
      7 # Column 3: 2 unit from the remaining free space
      8 
      9 col_dsc = [60, lv.grid_fr(1), lv.grid_fr(2), lv.GRID_TEMPLATE.LAST]
     10 
     11 # Row 1: fix width 60 px
     12 # Row 2: 1 unit from the remaining free space
     13 # Row 3: fix width 60 px
     14 
     15 row_dsc = [40, lv.grid_fr(1), 40, lv.GRID_TEMPLATE.LAST]
     16 
     17 # Create a container with grid
     18 cont = lv.obj(lv.scr_act())
     19 cont.set_size(300, 220)
     20 cont.center()
     21 cont.set_grid_dsc_array(col_dsc, row_dsc)
     22 
     23 for i in range(9):
     24     col = i % 3
     25     row = i // 3
     26 
     27     obj = lv.obj(cont)
     28     # Stretch the cell horizontally and vertically too
     29     # Set span to 1 to make the cell 1 column/row sized
     30     obj.set_grid_cell(lv.GRID_ALIGN.STRETCH, col, 1,
     31                       lv.GRID_ALIGN.STRETCH, row, 1)
     32 
     33     label = lv.label(obj)
     34     label.set_text("%d,%d"%(col, row))
     35     label.center()
     36