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_get_started_3.py (729B)

      1 def slider_event_cb(evt):
      2     slider = evt.get_target()
      3 
      4     # Refresh the text
      5     label.set_text(str(slider.get_value()))
      6 
      7 #
      8 # Create a slider and write its value on a label.
      9 #
     10 
     11 # Create a slider in the center of the display
     12 slider = lv.slider(lv.scr_act())
     13 slider.set_width(200)                                              # Set the width
     14 slider.center()                                                    # Align to the center of the parent (screen)
     15 slider.add_event_cb(slider_event_cb, lv.EVENT.VALUE_CHANGED, None) # Assign an event function
     16 
     17 # Create a label below the slider
     18 label = lv.label(lv.scr_act())
     19 label.set_text("0")
     20 label.align_to(slider, lv.ALIGN.OUT_TOP_MID, 0, -15)               # Align below the slider
     21 
     22