example(micropython): updated MicroPython examples according to LVGL changes (#4031)

This commit is contained in:
Uli Raich
2023-03-10 21:44:12 +01:00
committed by GitHub
parent 55c9a9220b
commit d1c6c61780
24 changed files with 394 additions and 225 deletions

View File

@@ -1,11 +1,13 @@
def event_cb(e):
# The original target of the event. Can be the buttons or the container
target = e.get_target_obj()
# print(type(target))
target = e.get_original_target_obj()
# The current target is always the container as the event is added to it
cont = e.get_target_obj()
# If container was clicked do nothing
if type(target) != type(lv.btn()):
if target == cont:
return
# Make the clicked buttons red
@@ -16,17 +18,17 @@ def event_cb(e):
#
cont = lv.obj(lv.scr_act())
cont.set_size(320, 200)
cont.set_size(290, 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.set_size(70, 50)
btn.add_flag(lv.obj.FLAG.EVENT_BUBBLE)
label = lv.label(btn)
label.set_text(str(i))
label.set_text("{:d}".format(i))
label.center()
cont.add_event(event_cb, lv.EVENT.CLICKED, None)