-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paththeme.py
More file actions
26 lines (19 loc) · 900 Bytes
/
theme.py
File metadata and controls
26 lines (19 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import lvgl as lv
from style import ButtonStyle, ButtonPressedStyle
class BaseTheme(lv.theme_t):
def __init__(self):
super().__init__()
self.button_style = ButtonStyle()
self.button_pressed_style = ButtonPressedStyle()
# This theme is based on active theme (material)
base_theme = lv.theme_get_from_obj(lv.scr_act())
# This theme will be applied only after base theme is applied
self.set_parent(base_theme)
# Set the "apply" callback of this theme to our custom callback
self.set_apply_cb(self.apply)
# Activate this theme on default display
lv.disp_get_default().set_theme(self)
def apply(self, theme, obj):
if obj.get_class() == lv.btn_class:
obj.add_style(self.button_style, lv.PART.MAIN)
obj.add_style(self.button_pressed_style, lv.PART.MAIN | lv.STATE.PRESSED)