-
Notifications
You must be signed in to change notification settings - Fork 3
/
ThreeBottomButtons.py
50 lines (39 loc) · 1.3 KB
/
ThreeBottomButtons.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Copyright (c) 2022 by GWENDESIGN. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
# Note: LVGL Micropython firmware (not UIFlow) is required for this example to run.
# https://github.com/lvgl/lv_micropython/tree/master/ports/esp32/boards/M5CORE2
import lvgl as lv
def btnl_event_cb(ev):
print("Btn Left clicked")
def btnm_event_cb(ev):
print("Btn Middle clicked")
def btnr_event_cb(ev):
print("Btn Right clicked")
scr = lv.obj()
scr.clear_flag(lv.obj.FLAG.SCROLLABLE)
style = lv.style_t()
style.init()
style.set_width(106)
style.set_height(50)
btnl = lv.btn(scr)
btnl.add_event_cb(btnl_event_cb,lv.EVENT.CLICKED, None)
btnl.add_style(style, 0)
btnl.align(lv.ALIGN.BOTTOM_LEFT, 0, 34)
label = lv.label(btnl)
label.align(lv.ALIGN.TOP_MID, 0, -8)
label.set_text("Left")
btnm = lv.btn(scr)
btnm.add_event_cb(btnm_event_cb,lv.EVENT.CLICKED, None)
btnm.add_style(style, 0)
btnm.align(lv.ALIGN.BOTTOM_MID, 0, 34)
label = lv.label(btnm)
label.align(lv.ALIGN.TOP_MID, 0, -8)
label.set_text("Middle")
btnr = lv.btn(scr)
btnr.add_event_cb(btnr_event_cb,lv.EVENT.CLICKED, None)
btnr.add_style(style, 0)
btnr.align(lv.ALIGN.BOTTOM_RIGHT, 0, 34)
label = lv.label(btnr)
label.align(lv.ALIGN.TOP_MID, 0, -8)
label.set_text("Right")
lv.scr_load(scr)