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_get_started_1.py (1109B)

      1 class CounterBtn():
      2     def __init__(self):
      3         self.cnt = 0
      4         #
      5         # Create a button with a label and react on click event.
      6         #
      7 
      8         btn = lv.btn(lv.scr_act())                               # Add a button the current screen
      9         btn.set_pos(10, 10)                                      # Set its position
     10         btn.set_size(120, 50)                                    # Set its size
     11         btn.align(lv.ALIGN.CENTER,0,0)
     12         btn.add_event_cb(self.btn_event_cb, lv.EVENT.ALL, None)  # Assign a callback to the button
     13         label = lv.label(btn)                                    # Add a label to the button
     14         label.set_text("Button")                                 # Set the labels text
     15         label.center()
     16 
     17     def btn_event_cb(self,evt):
     18         code = evt.get_code()
     19         btn = evt.get_target()
     20         if code == lv.EVENT.CLICKED:
     21             self.cnt += 1
     22 
     23         # Get the first child of the button which is the label and change its text
     24         label = btn.get_child(0)
     25         label.set_text("Button: " + str(self.cnt))
     26 
     27 
     28 counterBtn = CounterBtn()
     29