1def event_cb(e,label): 2 code = e.get_code() 3 if code == lv.EVENT.PRESSED: 4 label.set_text("The last button event:\nLV_EVENT_PRESSED") 5 elif code == lv.EVENT.CLICKED: 6 label.set_text("The last button event:\nLV_EVENT_CLICKED") 7 elif code == lv.EVENT.LONG_PRESSED: 8 label.set_text("The last button event:\nLV_EVENT_LONG_PRESSED") 9 elif code == lv.EVENT.LONG_PRESSED_REPEAT: 10 label.set_text("The last button event:\nLV_EVENT_LONG_PRESSED_REPEAT") 11btn = lv.btn(lv.scr_act()) 12btn.set_size(100, 50) 13btn.center() 14 15btn_label = lv.label(btn) 16btn_label.set_text("Click me!") 17btn_label.center() 18 19info_label = lv.label(lv.scr_act()) 20info_label.set_text("The last button event:\nNone") 21 22btn.add_event_cb(lambda e: event_cb(e,info_label), lv.EVENT.ALL, None) 23