acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

lv_example_checkbox_1.py (990B)

      1 def 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 
     13 lv.scr_act().set_flex_flow(lv.FLEX_FLOW.COLUMN)
     14 lv.scr_act().set_flex_align(lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.START, lv.FLEX_ALIGN.CENTER)
     15 
     16 cb = lv.checkbox(lv.scr_act())
     17 cb.set_text("Apple")
     18 cb.add_event_cb(event_handler, lv.EVENT.ALL, None)
     19 
     20 cb = lv.checkbox(lv.scr_act())
     21 cb.set_text("Banana")
     22 cb.add_state(lv.STATE.CHECKED)
     23 cb.add_event_cb(event_handler, lv.EVENT.ALL, None)
     24 
     25 cb = lv.checkbox(lv.scr_act())
     26 cb.set_text("Lemon")
     27 cb.add_state(lv.STATE.DISABLED)
     28 cb.add_event_cb(event_handler, lv.EVENT.ALL, None)
     29 
     30 cb = lv.checkbox(lv.scr_act())
     31 cb.add_state(lv.STATE.CHECKED | lv.STATE.DISABLED)
     32 cb.set_text("Melon")
     33 cb.add_event_cb(event_handler, lv.EVENT.ALL, None)
     34 
     35 cb.update_layout()
     36