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_style_14.py (1595B)

      1 # Will be called when the styles of the base theme are already added
      2 # to add new styles
      3 
      4 
      5 class NewTheme(lv.theme_t):
      6     def __init__(self):
      7         super().__init__()
      8         # Initialize the styles
      9         self.style_btn = lv.style_t()
     10         self.style_btn.init()
     11         self.style_btn.set_bg_color(lv.palette_main(lv.PALETTE.GREEN))
     12         self.style_btn.set_border_color(lv.palette_darken(lv.PALETTE.GREEN, 3))
     13         self.style_btn.set_border_width(3)
     14 
     15         # This theme is based on active theme
     16         th_act = lv.theme_get_from_obj(lv.scr_act())
     17         # This theme will be applied only after base theme is applied
     18         self.set_parent(th_act)
     19 
     20 
     21 class ExampleStyle_14:
     22 
     23     def __init__(self):
     24         #
     25         # Extending the current theme
     26         #
     27 
     28         btn = lv.btn(lv.scr_act())
     29         btn.align(lv.ALIGN.TOP_MID, 0, 20)
     30 
     31         label = lv.label(btn)
     32         label.set_text("Original theme")
     33 
     34         self.new_theme_init_and_set()
     35 
     36         btn = lv.btn(lv.scr_act())
     37         btn.align(lv.ALIGN.BOTTOM_MID, 0, -20)
     38 
     39         label = lv.label(btn)
     40         label.set_text("New theme")
     41 
     42     def new_theme_apply_cb(self, th, obj):
     43         print(th,obj)
     44         if obj.get_class() == lv.btn_class:
     45             obj.add_style(self.th_new.style_btn, 0)
     46 
     47     def new_theme_init_and_set(self):
     48         print("new_theme_init_and_set")
     49         # Initialize the new theme from the current theme
     50         self.th_new = NewTheme()
     51         self.th_new.set_apply_cb(self.new_theme_apply_cb)
     52         lv.disp_get_default().set_theme(self.th_new)
     53 
     54 
     55 exampleStyle_14 = ExampleStyle_14()