adding micropython examples (#2286)
* adding micropython examples * adding micropython examples
This commit is contained in:
25
examples/event/lv_example_event_1.py
Normal file
25
examples/event/lv_example_event_1.py
Normal file
@@ -0,0 +1,25 @@
|
||||
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()
|
||||
btn.add_event_cb(self.event_cb, lv.EVENT.CLICKED, None)
|
||||
|
||||
label = lv.label(btn)
|
||||
label.set_text("Click me!");
|
||||
label.center()
|
||||
|
||||
def event_cb(self,e):
|
||||
print("Clicked");
|
||||
|
||||
btn = lv.btn.__cast__(e.get_target())
|
||||
label = btn.get_child(0)
|
||||
label.set_text(str(self.cnt))
|
||||
self.cnt += 1
|
||||
|
||||
evt1 = Event_1()
|
||||
Reference in New Issue
Block a user