1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00
lvgl/examples/event/lv_example_event_2.py

23 lines
824 B
Python

def event_cb(e,label):
code = e.get_code()
if code == lv.EVENT.PRESSED:
label.set_text("The last button event:\nLV_EVENT_PRESSED")
elif code == lv.EVENT.CLICKED:
label.set_text("The last button event:\nLV_EVENT_CLICKED")
elif code == lv.EVENT.LONG_PRESSED:
label.set_text("The last button event:\nLV_EVENT_LONG_PRESSED")
elif code == lv.EVENT.LONG_PRESSED_REPEAT:
label.set_text("The last button event:\nLV_EVENT_LONG_PRESSED_REPEAT")
button = lv.button(lv.screen_active())
button.set_size(100, 50)
button.center()
button_label = lv.label(button)
button_label.set_text("Click me!")
button_label.center()
info_label = lv.label(lv.screen_active())
info_label.set_text("The last button event:\nNone")
button.add_event(lambda e: event_cb(e,info_label), lv.EVENT.ALL, None)