1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00
lvgl/examples/layouts/flex/lv_example_flex_1.py
Amir Gonnen 7a23be73ab
fix(examples) adjust constant names in Micropython examples (#3532)
Due to spurious enums (https://github.com/lvgl/lv_binding_micropython/issues/199) wrong constant names were generated. Fix these constants.
2022-07-30 11:10:56 -04:00

34 lines
843 B
Python

#
# A simple row and a column layout with flexbox
#
# Create a container with ROW flex direction
cont_row = lv.obj(lv.scr_act())
cont_row.set_size(300, 75)
cont_row.align(lv.ALIGN.TOP_MID, 0, 5)
cont_row.set_flex_flow(lv.FLEX_FLOW.ROW)
# Create a container with COLUMN flex direction
cont_col = lv.obj(lv.scr_act())
cont_col.set_size(200, 150)
cont_col.align_to(cont_row, lv.ALIGN.OUT_BOTTOM_MID, 0, 5)
cont_col.set_flex_flow(lv.FLEX_FLOW.COLUMN)
for i in range(10):
# Add items to the row
obj = lv.btn(cont_row)
obj.set_size(100, lv.pct(100))
label = lv.label(obj)
label.set_text("Item: {:d}".format(i))
label.center()
# Add items to the column
obj = lv.btn(cont_col)
obj.set_size(lv.pct(100), lv.SIZE_CONTENT)
label = lv.label(obj)
label.set_text("Item: {:d}".format(i))
label.center()