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_event_2.py (788B)

      1 def 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")
     11 btn = lv.btn(lv.scr_act())
     12 btn.set_size(100, 50)
     13 btn.center()
     14 
     15 btn_label = lv.label(btn)
     16 btn_label.set_text("Click me!")
     17 btn_label.center()
     18 
     19 info_label = lv.label(lv.scr_act())
     20 info_label.set_text("The last button event:\nNone")
     21 
     22 btn.add_event_cb(lambda e: event_cb(e,info_label), lv.EVENT.ALL, None)