2021-06-07 13:56:08 +02:00
|
|
|
class Event_1():
|
|
|
|
def __init__(self):
|
|
|
|
self.cnt = 1
|
|
|
|
#
|
|
|
|
# Add click event to a button
|
|
|
|
#
|
|
|
|
|
|
|
|
btn = lv.btn(lv.scr_act())
|
|
|
|
btn.set_size(100, 50)
|
|
|
|
btn.center()
|
2023-02-20 20:50:58 +01:00
|
|
|
btn.add_event(self.event_cb, lv.EVENT.CLICKED, None)
|
2022-03-21 18:25:51 +08:00
|
|
|
|
2021-06-07 13:56:08 +02:00
|
|
|
label = lv.label(btn)
|
2021-12-05 14:41:17 +01:00
|
|
|
label.set_text("Click me!")
|
2021-06-07 13:56:08 +02:00
|
|
|
label.center()
|
|
|
|
|
|
|
|
def event_cb(self,e):
|
2021-12-05 14:41:17 +01:00
|
|
|
print("Clicked")
|
2022-03-21 18:25:51 +08:00
|
|
|
|
2023-02-20 20:50:58 +01:00
|
|
|
btn = e.get_target_obj()
|
2021-06-07 13:56:08 +02:00
|
|
|
label = btn.get_child(0)
|
|
|
|
label.set_text(str(self.cnt))
|
|
|
|
self.cnt += 1
|
|
|
|
|
|
|
|
evt1 = Event_1()
|