1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00
lvgl/examples/get_started/lv_example_get_started_3.py
KyleParker-Gongyuan 8d8aaed0e3
fix(examples) correct comment in slider example (#3419)
The label is above the slider in this example, not below it.
2022-06-21 08:50:55 -04:00

23 lines
729 B
Python

def slider_event_cb(evt):
slider = evt.get_target()
# Refresh the text
label.set_text(str(slider.get_value()))
#
# Create a slider and write its value on a label.
#
# Create a slider in the center of the display
slider = lv.slider(lv.scr_act())
slider.set_width(200) # Set the width
slider.center() # Align to the center of the parent (screen)
slider.add_event_cb(slider_event_cb, lv.EVENT.VALUE_CHANGED, None) # Assign an event function
# Create a label above the slider
label = lv.label(lv.scr_act())
label.set_text("0")
label.align_to(slider, lv.ALIGN.OUT_TOP_MID, 0, -15) # Align below the slider