Color Definitions#
Material colors palette to use in For example, kivymd.theming.ThemeManager
.
colors
is a dict-in-dict where the first key is a value from
palette
and the second key is a value from hue
. Color is a hex
value, a string of 6 characters (0-9, A-F) written in uppercase.colors["Red"]["900"]
is "B71C1C"
.
API - kivymd.color_definitions
#
- kivymd.color_definitions.colors#
Color palette. Taken from 2014 Material Design color palettes.
To demonstrate the shades of the palette, you can run the following code:
from kivy.lang import Builder from kivy.properties import ListProperty, StringProperty from kivymd.color_definitions import colors from kivymd.uix.tab import MDTabsBase from kivymd.uix.boxlayout import MDBoxLayout demo = ''' <Root@MDBoxLayout> orientation: 'vertical' MDTopAppBar: title: app.title MDTabs: id: android_tabs on_tab_switch: app.on_tab_switch(*args) size_hint_y: None height: "48dp" tab_indicator_anim: False RecycleView: id: rv key_viewclass: "viewclass" key_size: "height" RecycleBoxLayout: default_size: None, dp(48) default_size_hint: 1, None size_hint_y: None height: self.minimum_height orientation: "vertical" <ItemColor> size_hint_y: None height: "42dp" MDLabel: text: root.text halign: "center" <Tab> ''' from kivy.factory import Factory from kivymd.app import MDApp class Tab(MDBoxLayout, MDTabsBase): pass class ItemColor(MDBoxLayout): text = StringProperty() color = ListProperty() class Palette(MDApp): title = "Colors definitions" def build(self): Builder.load_string(demo) self.screen = Factory.Root() for name_tab in colors.keys(): tab = Tab(title=name_tab) self.screen.ids.android_tabs.add_widget(tab) return self.screen def on_tab_switch( self, instance_tabs, instance_tab, instance_tabs_label, tab_text ): self.screen.ids.rv.data = [] if not tab_text: tab_text = 'Red' for value_color in colors[tab_text]: self.screen.ids.rv.data.append( { "viewclass": "ItemColor", "md_bg_color": colors[tab_text][value_color], "title": value_color, } ) def on_start(self): self.on_tab_switch( None, None, None, self.screen.ids.android_tabs.ids.layout.children[-1].text, ) Palette().run()
- kivymd.color_definitions.palette = ['Red', 'Pink', 'Purple', 'DeepPurple', 'Indigo', 'Blue', 'LightBlue', 'Cyan', 'Teal', 'Green', 'LightGreen', 'Lime', 'Yellow', 'Amber', 'Orange', 'DeepOrange', 'Brown', 'Gray', 'BlueGray']#
Valid values for color palette selecting.
- kivymd.color_definitions.hue = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900', 'A100', 'A200', 'A400', 'A700']#
Valid values for color hue selecting.
- kivymd.color_definitions.light_colors#
Which colors are light. Other are dark.
- kivymd.color_definitions.text_colors#
Text colors generated from
light_colors
. “000000” for light and “FFFFFF” for dark.How to generate text_colors dict
text_colors = {} for p in palette: text_colors[p] = {} for h in hue: if h in light_colors[p]: text_colors[p][h] = "000000" else: text_colors[p][h] = "FFFFFF"
- kivymd.color_definitions.theme_colors = ['Primary', 'Secondary', 'Background', 'Surface', 'Error', 'On_Primary', 'On_Secondary', 'On_Background', 'On_Surface', 'On_Error']#
Valid theme colors.