1#!/opt/bin/lv_micropython -i
2import lvgl as lv
3import display_driver
4def event_handler(e):
5    code = e.get_code()
6    obj = e.get_target()
7    if code == lv.EVENT.CLICKED:
8            print("Clicked: list1." + list1.get_btn_text(obj))
9
10# Create a list
11list1 = lv.list(lv.scr_act())
12list1.set_size(180, 220)
13list1.center()
14
15# Add buttons to the list
16list1.add_text("File")
17btn_new = list1.add_btn(lv.SYMBOL.FILE, "New")
18btn_new.add_event_cb(event_handler,lv.EVENT.ALL, None)
19btn_open = list1.add_btn(lv.SYMBOL.DIRECTORY, "Open")
20btn_open.add_event_cb(event_handler,lv.EVENT.ALL, None)
21btn_save = list1.add_btn(lv.SYMBOL.SAVE, "Save")
22btn_save.add_event_cb(event_handler,lv.EVENT.ALL, None)
23btn_delete = list1.add_btn(lv.SYMBOL.CLOSE, "Delete")
24btn_delete.add_event_cb(event_handler,lv.EVENT.ALL, None)
25btn_edit = list1.add_btn(lv.SYMBOL.EDIT, "Edit")
26btn_edit.add_event_cb(event_handler,lv.EVENT.ALL, None)
27
28list1.add_text("Connectivity")
29btn_bluetooth = list1.add_btn(lv.SYMBOL.BLUETOOTH, "Bluetooth")
30btn_bluetooth.add_event_cb(event_handler,lv.EVENT.ALL, None)
31btn_navig = list1.add_btn(lv.SYMBOL.GPS, "Navigation")
32btn_navig.add_event_cb(event_handler,lv.EVENT.ALL, None)
33btn_USB = list1.add_btn(lv.SYMBOL.USB, "USB")
34btn_USB.add_event_cb(event_handler,lv.EVENT.ALL, None)
35btn_battery = list1.add_btn(lv.SYMBOL.BATTERY_FULL, "Battery")
36btn_battery.add_event_cb(event_handler,lv.EVENT.ALL, None)
37
38list1.add_text("Exit")
39btn_apply = list1.add_btn(lv.SYMBOL.OK, "Apply")
40btn_apply.add_event_cb(event_handler,lv.EVENT.ALL, None)
41btn_close = list1.add_btn(lv.SYMBOL.CLOSE, "Close")
42btn_close.add_event_cb(event_handler,lv.EVENT.ALL, None)
43
44