color_theme.py
from kivy.lang import Builder
from kivymd.app import MDApp
class MainApp(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
self.theme_cls.primary_palette = "Blue"
#self.theme_cls.accent_palette = "Red"
return Builder.load_file('color_theme.kv')
#'Red', 'Pink', 'Purple', 'DeepPurple',
#'Indigo', 'Blue', 'LightBlue', 'Cyan',
#'Teal', 'Green', 'LightGreen', 'Lime',
#'Yellow', 'Amber', 'Orange', 'DeepOrange',
#'Brown', 'Gray', "BlueGray"
MainApp().run()
color_theme.kv
Screen:
MDRaisedButton:
text:"Light Button"
pos_hint: {"center_x": 0.5, "center_y": 0.7}
md_bg_color: app.theme_cls.primary_light
MDRaisedButton:
text:"Second Button"
pos_hint: {"center_x": 0.5, "center_y": 0.5}
MDRaisedButton:
text:"Third Button"
pos_hint: {"center_x": 0.5, "center_y": 0.3}
md_bg_color: app.theme_cls.primary_dark
Notes:
The colors used in theme_cls are listed.
accent_palette is used on some widgets… to be seen...
primary_light is a lighter shade of the theme color.
primary_dark is a darker shade of the theme color.