1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00
lvgl/examples/widgets/spinbox/lv_example_spinbox_1.py
2023-11-28 15:36:51 +01:00

31 lines
963 B
Python

def increment_event_cb(e):
code = e.get_code()
if code == lv.EVENT.SHORT_CLICKED or code == lv.EVENT.LONG_PRESSED_REPEAT:
spinbox.increment()
def decrement_event_cb(e):
code = e.get_code()
if code == lv.EVENT.SHORT_CLICKED or code == lv.EVENT.LONG_PRESSED_REPEAT:
spinbox.decrement()
spinbox = lv.spinbox(lv.screen_active())
spinbox.set_range(-1000, 25000)
spinbox.set_digit_format(5, 2)
spinbox.step_prev()
spinbox.set_width(100)
spinbox.center()
h = spinbox.get_height()
button = lv.button(lv.screen_active())
button.set_size(h, h)
button.align_to(spinbox, lv.ALIGN.OUT_RIGHT_MID, 5, 0)
button.set_style_bg_image_src(lv.SYMBOL.PLUS, 0)
button.add_event_cb(increment_event_cb, lv.EVENT.ALL, None)
button = lv.button(lv.screen_active())
button.set_size(h, h)
button.align_to(spinbox, lv.ALIGN.OUT_LEFT_MID, -5, 0)
button.set_style_bg_image_src(lv.SYMBOL.MINUS, 0)
button.add_event_cb(decrement_event_cb, lv.EVENT.ALL, None)