In this video I’ll show you how to select and use Color Themes with KivyMD.

With KivyMD, you don’t so much choose colors for your app and widgets, instead you choose a broad color theme made up of one strong color, and KivyMD applies that theme to all of your widgets itself.

You have some latitude in changing the lightness and darkness of certain things, but that’s really all. This is in keeping with the precepts of Google’s Material Design (MD).

Python Code: color_theme.py
GitHub Code: color_theme.py

from kivy.lang import Builder
from kivymd.app import MDApp

#‘Red’, ‘Pink’, ‘Purple’, ‘DeepPurple’, 
#‘Indigo’, ‘Blue’, ‘LightBlue’, ‘Cyan’, 
#‘Teal’, ‘Green’, ‘LightGreen’, ‘Lime’, 
#‘Yellow’, ‘Amber’, ‘Orange’, ‘DeepOrange’, 
#‘Brown’, ‘Gray’, ‘BlueGray’.
class MainApp(MDApp):
	def build(self):
		self.theme_cls.theme_style = "Dark"
		self.theme_cls.primary_palette = "Indigo"
		self.theme_cls.accent_palette = "Red"
		return Builder.load_file('color_theme.kv')

		

MainApp().run()

Kivy Design Code: color_theme.kv
GitHub Code: color_theme.kv

Screen:

    MDRectangleFlatButton:
        text: "Light Button"
        pos_hint: {"center_x": 0.5, "center_y": 0.7}
        md_bg_color: app.theme_cls.primary_light

    MDRaisedButton:
        text: "Primary Button"
        pos_hint: {"center_x": 0.5, "center_y": 0.5}


    MDRaisedButton:
        text: "Dark Button"
        pos_hint: {"center_x": 0.5, "center_y": 0.3}
        md_bg_color: app.theme_cls.primary_dark


John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

2 comments

Your email address will not be published. Required fields are marked *

John Elder