A39模拟器
This commit is contained in:
13
MXC-A39/lvgl/examples/widgets/spinbox/index.rst
Normal file
13
MXC-A39/lvgl/examples/widgets/spinbox/index.rst
Normal file
@ -0,0 +1,13 @@
|
||||
C
|
||||
^
|
||||
|
||||
Simple Spinbox
|
||||
"""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/spinbox/lv_example_spinbox_1
|
||||
:language: c
|
||||
|
||||
MicroPython
|
||||
^^^^^^^^^^^
|
||||
|
||||
No examples yet.
|
48
MXC-A39/lvgl/examples/widgets/spinbox/lv_example_spinbox_1.c
Normal file
48
MXC-A39/lvgl/examples/widgets/spinbox/lv_example_spinbox_1.c
Normal file
@ -0,0 +1,48 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_SPINBOX && LV_BUILD_EXAMPLES
|
||||
|
||||
static lv_obj_t * spinbox;
|
||||
|
||||
|
||||
static void lv_spinbox_increment_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
|
||||
lv_spinbox_increment(spinbox);
|
||||
}
|
||||
}
|
||||
|
||||
static void lv_spinbox_decrement_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
|
||||
lv_spinbox_decrement(spinbox);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void lv_example_spinbox_1(void)
|
||||
{
|
||||
spinbox = lv_spinbox_create(lv_scr_act());
|
||||
lv_spinbox_set_range(spinbox, -1000, 25000);
|
||||
lv_spinbox_set_digit_format(spinbox, 5, 2);
|
||||
lv_spinbox_step_prev(spinbox);
|
||||
lv_obj_set_width(spinbox, 100);
|
||||
lv_obj_center(spinbox);
|
||||
|
||||
lv_coord_t h = lv_obj_get_height(spinbox);
|
||||
|
||||
lv_obj_t * btn = lv_btn_create(lv_scr_act());
|
||||
lv_obj_set_size(btn, h, h);
|
||||
lv_obj_align_to(btn, spinbox, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
|
||||
lv_obj_set_style_bg_img_src(btn, LV_SYMBOL_PLUS, 0);
|
||||
lv_obj_add_event_cb(btn, lv_spinbox_increment_event_cb, LV_EVENT_ALL, NULL);
|
||||
|
||||
btn = lv_btn_create(lv_scr_act());
|
||||
lv_obj_set_size(btn, h, h);
|
||||
lv_obj_align_to(btn, spinbox, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
lv_obj_set_style_bg_img_src(btn, LV_SYMBOL_MINUS, 0);
|
||||
lv_obj_add_event_cb(btn, lv_spinbox_decrement_event_cb, LV_EVENT_ALL, NULL);
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,13 @@
|
||||
def event_handler(obj, event):
|
||||
if event == lv.EVENT.VALUE_CHANGED:
|
||||
print("Value: %d" % obj.get_value())
|
||||
elif event == lv.EVENT.CLICKED:
|
||||
# For simple test: Click the spinbox to increment its value
|
||||
obj.increment()
|
||||
|
||||
spinbox = lv.spinbox(lv.scr_act())
|
||||
spinbox.set_digit_format(5, 3)
|
||||
spinbox.step_prev()
|
||||
spinbox.set_width(100)
|
||||
spinbox.align(None, lv.ALIGN.CENTER, 0, 0)
|
||||
spinbox.set_event_cb(event_handler)
|
Reference in New Issue
Block a user