acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
lv_example_btn_1.py (768B)
1 def 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 10 btn1 = lv.btn(lv.scr_act()) 11 12 # attach the callback 13 btn1.add_event_cb(event_handler,lv.EVENT.ALL, None) 14 15 btn1.align(lv.ALIGN.CENTER,0,-40) 16 label=lv.label(btn1) 17 label.set_text("Button") 18 19 # create a toggle button 20 btn2 = lv.btn(lv.scr_act()) 21 22 # attach the callback 23 #btn2.add_event_cb(event_handler,lv.EVENT.VALUE_CHANGED,None) 24 btn2.add_event_cb(event_handler,lv.EVENT.ALL, None) 25 26 btn2.align(lv.ALIGN.CENTER,0,40) 27 btn2.add_flag(lv.obj.FLAG.CHECKABLE) 28 btn2.set_height(lv.SIZE.CONTENT) 29 30 label=lv.label(btn2) 31 label.set_text("Toggle") 32 label.center()