2021-06-07 13:56:08 +02:00
|
|
|
#
|
|
|
|
# A default slider with a label displaying the current value
|
|
|
|
#
|
|
|
|
def slider_event_cb(e):
|
2021-02-08 09:53:03 +01:00
|
|
|
|
2021-06-07 13:56:08 +02:00
|
|
|
slider = lv.slider.__cast__(e.get_target())
|
|
|
|
slider_label.set_text("{:d}%".format(slider.get_value()))
|
|
|
|
slider_label.align_to(slider, lv.ALIGN.OUT_BOTTOM_MID, 0, 10)
|
2021-02-08 09:53:03 +01:00
|
|
|
|
2021-06-07 13:56:08 +02:00
|
|
|
# Create a slider in the center of the display
|
|
|
|
slider = lv.slider(lv.scr_act())
|
|
|
|
slider.center()
|
|
|
|
slider.add_event_cb(slider_event_cb, lv.EVENT.VALUE_CHANGED, None)
|
2021-02-08 09:53:03 +01:00
|
|
|
|
2021-06-07 13:56:08 +02:00
|
|
|
# Create a label below the slider
|
|
|
|
slider_label = lv.label(lv.scr_act())
|
|
|
|
slider_label.set_text("0%")
|
2021-02-08 09:53:03 +01:00
|
|
|
|
2021-06-07 13:56:08 +02:00
|
|
|
slider_label.align_to(slider, lv.ALIGN.OUT_BOTTOM_MID, 0, 10)
|
2021-02-08 09:53:03 +01:00
|
|
|
|