A39模拟器
This commit is contained in:
13
MXC-A39/lvgl/examples/widgets/list/index.rst
Normal file
13
MXC-A39/lvgl/examples/widgets/list/index.rst
Normal file
@ -0,0 +1,13 @@
|
||||
C
|
||||
^
|
||||
|
||||
Simple List
|
||||
""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/list/lv_example_list_1
|
||||
:language: c
|
||||
|
||||
MicroPython
|
||||
^^^^^^^^^^^
|
||||
|
||||
No examples yet.
|
52
MXC-A39/lvgl/examples/widgets/list/lv_example_list_1.c
Normal file
52
MXC-A39/lvgl/examples/widgets/list/lv_example_list_1.c
Normal file
@ -0,0 +1,52 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_LIST && LV_BUILD_EXAMPLES
|
||||
static lv_obj_t * list1;
|
||||
|
||||
static void event_handler(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_CLICKED) {
|
||||
LV_LOG_USER("Clicked: %s", lv_list_get_btn_text(list1, obj));
|
||||
}
|
||||
}
|
||||
void lv_example_list_1(void)
|
||||
{
|
||||
/*Create a list*/
|
||||
list1 = lv_list_create(lv_scr_act());
|
||||
lv_obj_set_size(list1, 180, 220);
|
||||
lv_obj_center(list1);
|
||||
|
||||
/*Add buttons to the list*/
|
||||
lv_obj_t * btn;
|
||||
|
||||
lv_list_add_text(list1, "File");
|
||||
btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, "New");
|
||||
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
||||
btn = lv_list_add_btn(list1, LV_SYMBOL_DIRECTORY, "Open");
|
||||
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
||||
btn = lv_list_add_btn(list1, LV_SYMBOL_SAVE, "Save");
|
||||
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
||||
btn = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Delete");
|
||||
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
||||
btn = lv_list_add_btn(list1, LV_SYMBOL_EDIT, "Edit");
|
||||
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
lv_list_add_text(list1, "Connectivity");
|
||||
btn = lv_list_add_btn(list1, LV_SYMBOL_BLUETOOTH, "Bluetooth");
|
||||
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
||||
btn = lv_list_add_btn(list1, LV_SYMBOL_GPS, "Navigation");
|
||||
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
||||
btn = lv_list_add_btn(list1, LV_SYMBOL_USB, "USB");
|
||||
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
||||
btn = lv_list_add_btn(list1, LV_SYMBOL_BATTERY_FULL, "Battery");
|
||||
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
lv_list_add_text(list1, "Exit");
|
||||
btn = lv_list_add_btn(list1, LV_SYMBOL_OK, "Apply");
|
||||
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
||||
btn = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Close");
|
||||
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
||||
}
|
||||
|
||||
#endif
|
25
MXC-A39/lvgl/examples/widgets/list/lv_example_list_1.py
Normal file
25
MXC-A39/lvgl/examples/widgets/list/lv_example_list_1.py
Normal file
@ -0,0 +1,25 @@
|
||||
def event_handler(obj, event):
|
||||
if event == lv.EVENT.CLICKED:
|
||||
print("Clicked: %s" % lv.list.get_btn_text(obj))
|
||||
|
||||
# Create a list
|
||||
list1 = lv.list(lv.scr_act())
|
||||
list1.set_size(160, 200)
|
||||
list1.align(None, lv.ALIGN.CENTER, 0, 0)
|
||||
|
||||
# Add buttons to the list
|
||||
|
||||
list_btn = list1.add_btn(lv.SYMBOL.FILE, "New")
|
||||
list_btn.set_event_cb(event_handler)
|
||||
|
||||
list_btn = list1.add_btn(lv.SYMBOL.DIRECTORY, "Open")
|
||||
list_btn.set_event_cb(event_handler)
|
||||
|
||||
list_btn = list1.add_btn(lv.SYMBOL.CLOSE, "Delete")
|
||||
list_btn.set_event_cb(event_handler)
|
||||
|
||||
list_btn = list1.add_btn(lv.SYMBOL.EDIT, "Edit")
|
||||
list_btn.set_event_cb(event_handler)
|
||||
|
||||
list_btn = list1.add_btn(lv.SYMBOL.SAVE, "Save")
|
||||
list_btn.set_event_cb(event_handler)
|
Reference in New Issue
Block a user