1def event_handler(e): 2 code = e.get_code() 3 obj = e.get_target() 4 if code == lv.EVENT.VALUE_CHANGED: 5 txt = obj.get_text() 6 if obj.get_state() & lv.STATE.CHECKED: 7 state = "Checked" 8 else: 9 state = "Unchecked" 10 print(txt + ":" + state) 11 12 13lv.scr_act().set_flex_flow(lv.FLEX_FLOW.COLUMN) 14lv.scr_act().set_flex_align(lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.START, lv.FLEX_ALIGN.CENTER) 15 16cb = lv.checkbox(lv.scr_act()) 17cb.set_text("Apple") 18cb.add_event_cb(event_handler, lv.EVENT.ALL, None) 19 20cb = lv.checkbox(lv.scr_act()) 21cb.set_text("Banana") 22cb.add_state(lv.STATE.CHECKED) 23cb.add_event_cb(event_handler, lv.EVENT.ALL, None) 24 25cb = lv.checkbox(lv.scr_act()) 26cb.set_text("Lemon") 27cb.add_state(lv.STATE.DISABLED) 28cb.add_event_cb(event_handler, lv.EVENT.ALL, None) 29 30cb = lv.checkbox(lv.scr_act()) 31cb.add_state(lv.STATE.CHECKED | lv.STATE.DISABLED) 32cb.set_text("Melon") 33cb.add_event_cb(event_handler, lv.EVENT.ALL, None) 34 35cb.update_layout() 36 37