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_3.py (728B)

      1 def event_cb(e):
      2 
      3     # The original target of the event. Can be the buttons or the container
      4     target = e.get_target()
      5     # print(type(target))
      6 
      7     # If container was clicked do nothing
      8     if type(target) != type(lv.btn()):
      9         return
     10 
     11     # Make the clicked buttons red
     12     target.set_style_bg_color(lv.palette_main(lv.PALETTE.RED), 0)
     13 
     14 #
     15 # Demonstrate event bubbling
     16 #
     17 
     18 cont = lv.obj(lv.scr_act())
     19 cont.set_size(320, 200)
     20 cont.center()
     21 cont.set_flex_flow(lv.FLEX_FLOW.ROW_WRAP)
     22 
     23 for i in range(30):
     24     btn = lv.btn(cont)
     25     btn.set_size(80, 50)
     26     btn.add_flag(lv.obj.FLAG.EVENT_BUBBLE)
     27 
     28     label = lv.label(btn)
     29     label.set_text(str(i))
     30     label.center()
     31 
     32 cont.add_event_cb(event_cb, lv.EVENT.CLICKED, None)