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_btnmatrix_1.py (690B)

      1 def event_handler(evt):
      2     code = evt.get_code()
      3     obj  = evt.get_target()
      4 
      5     if code == lv.EVENT.VALUE_CHANGED :
      6         id = obj.get_selected_btn()
      7         txt = obj.get_btn_text(id)
      8 
      9         print("%s was pressed"%txt)
     10 
     11 btnm_map = ["1", "2", "3", "4", "5", "\n",
     12             "6", "7", "8", "9", "0", "\n",
     13             "Action1", "Action2", ""]
     14 
     15 btnm1 = lv.btnmatrix(lv.scr_act())
     16 btnm1.set_map(btnm_map)
     17 btnm1.set_btn_width(10, 2)        # Make "Action1" twice as wide as "Action2"
     18 btnm1.set_btn_ctrl(10, lv.btnmatrix.CTRL.CHECKABLE)
     19 btnm1.set_btn_ctrl(11, lv.btnmatrix.CTRL.CHECKED)
     20 btnm1.align(lv.ALIGN.CENTER, 0, 0)
     21 btnm1.add_event_cb(event_handler, lv.EVENT.ALL, None)
     22 
     23 
     24 #endif