KivyMD
KivyMD copied to clipboard
Dynamic colors are not updated if they were set in Python code
Dynamic colors are not updated if they were set in Python code.
from kivymd.app import MDApp
from kivymd.uix.button import MDButton, MDButtonText
from kivymd.uix.screen import MDScreen
class Example(MDApp):
def build(self):
return MDScreen(
MDButton(
MDButtonText(
text="Outline",
theme_text_color="Custom",
text_color=self.theme_cls.errorColor,
),
style="outlined",
theme_line_color="Custom",
line_color=self.theme_cls.errorColor,
pos_hint={"center_x": .5, "center_y": .5},
on_release=lambda x: self.theme_cls.switch_theme(),
),
md_bg_color=self.theme_cls.backgroundColor,
)
Example().run()
In previous versions of the KivyMD library, there were only two dynamic colors - black and white for the background and text of dark and light themes. And there were no problems with the color of the text and background when switching the theme from light to dark and vice versa. In version KivyMD 2.0.0, we have a whole palette of dynamic colors. Accordingly, in order to make binding for updating colors, we need to know exactly what type of color a particular widget uses.