1def event_handler(evt):
2    code = evt.get_code()
3
4    if code == lv.EVENT.CLICKED:
5            print("Clicked event seen")
6    elif code == lv.EVENT.VALUE_CHANGED:
7        print("Value changed seen")
8
9# create a simple button
10btn1 = lv.btn(lv.scr_act())
11
12# attach the callback
13btn1.add_event_cb(event_handler,lv.EVENT.ALL, None)
14
15btn1.align(lv.ALIGN.CENTER,0,-40)
16label=lv.label(btn1)
17label.set_text("Button")
18
19# create a toggle button
20btn2 = lv.btn(lv.scr_act())
21
22# attach the callback
23#btn2.add_event_cb(event_handler,lv.EVENT.VALUE_CHANGED,None)
24btn2.add_event_cb(event_handler,lv.EVENT.ALL, None)
25
26btn2.align(lv.ALIGN.CENTER,0,40)
27btn2.add_flag(lv.obj.FLAG.CHECKABLE)
28btn2.set_height(lv.SIZE.CONTENT)
29
30label=lv.label(btn2)
31label.set_text("Toggle")
32label.center()
33