Tactiliest/libs/lvgl/examples/event/lv_example_event_3.py
Ken Van Hoeylandt 6bd65abbb4
Tactility modules refactored (#13)
* refactor modules

* moved esp_lvgl_port to libs/

* added missing file

* fix for sim build

* various sim/pc fixes

* lvgl improvements

* added missing cmake files
2024-01-20 14:10:19 +01:00

33 lines
728 B
Python

def event_cb(e):
# The original target of the event. Can be the buttons or the container
target = e.get_target()
# print(type(target))
# If container was clicked do nothing
if type(target) != type(lv.btn()):
return
# Make the clicked buttons red
target.set_style_bg_color(lv.palette_main(lv.PALETTE.RED), 0)
#
# Demonstrate event bubbling
#
cont = lv.obj(lv.scr_act())
cont.set_size(320, 200)
cont.center()
cont.set_flex_flow(lv.FLEX_FLOW.ROW_WRAP)
for i in range(30):
btn = lv.btn(cont)
btn.set_size(80, 50)
btn.add_flag(lv.obj.FLAG.EVENT_BUBBLE)
label = lv.label(btn)
label.set_text(str(i))
label.center()
cont.add_event_cb(event_cb, lv.EVENT.CLICKED, None)