How to use the kivymd.color_definitions.colors function in kivymd

To help you get started, we’ve selected a few kivymd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HeaTTheatR / KivyMD / kivymd / uix / slider.py View on Github external
def _set_colors(self, *args):
        if self.theme_cls.theme_style == "Dark":
            self._track_color_normal = get_color_from_hex("FFFFFF")
            self._track_color_normal[3] = 0.3
            self._track_color_active = self._track_color_normal
            self._track_color_disabled = self._track_color_normal
            self.thumb_color = get_color_from_hex(colors["Gray"]["400"])
            self.thumb_color_down = get_color_from_hex(
                colors[self.theme_cls.primary_palette]["200"]
            )
            self.thumb_color_disabled = get_color_from_hex(
                colors["Gray"]["800"]
            )
        else:
            self._track_color_normal = get_color_from_hex("000000")
            self._track_color_normal[3] = 0.26
            self._track_color_active = get_color_from_hex("000000")
            self._track_color_active[3] = 0.38
            self._track_color_disabled = get_color_from_hex("000000")
            self._track_color_disabled[3] = 0.26
            self.thumb_color_down = self.theme_cls.primary_color
github AndreMiras / KivyMD / kivymd / theming.py View on Github external
def _get_bg_dark(self, opposite=False):
        theme_style = self._get_theme_style(opposite)
        if theme_style == 'Light':
            return get_color_from_hex(colors['Light']['AppBar'])
        elif theme_style == 'Dark':
            return get_color_from_hex(colors['Dark']['AppBar'])
github AndreMiras / KivyMD / kivymd / selectioncontrols.py View on Github external
def _set_colors(self, *args):
        self._track_color_normal = self.theme_cls.disabled_hint_text_color
        if self.theme_cls.theme_style == 'Dark':
            self._track_color_active = self.theme_cls.primary_color
            self._track_color_active[3] = .5
            self._track_color_disabled = get_color_from_hex('FFFFFF')
            self._track_color_disabled[3] = .1
            self.thumb_color = get_color_from_hex(colors['Grey']['400'])
            self.thumb_color_down = get_color_from_hex(
                colors[self.theme_cls.primary_palette]['200'])
            self.thumb_color_disabled = get_color_from_hex(
                colors['Grey']['800'])
        else:
            self._track_color_active = get_color_from_hex(
                colors[self.theme_cls.primary_palette]['200'])
            self._track_color_active[3] = .5
            self._track_color_disabled = self.theme_cls.disabled_hint_text_color
            self.thumb_color_down = self.theme_cls.primary_color
            self.thumb_color_disabled = get_color_from_hex(
                colors['Grey']['400'])
github HeaTTheatR / KivyMD / kivymd / theming_dynamic_text.py View on Github external
def get_contrast_text_color(color, use_color_brightness=True):
    if use_color_brightness:
        contrast_color = _black_or_white_by_color_brightness(color)
    else:
        contrast_color = _black_or_white_by_contrast_ratio(color)
    if contrast_color == "white":
        return 1, 1, 1, 1
    else:
        return 0, 0, 0, 1


if __name__ == "__main__":
    from kivy.utils import get_color_from_hex
    from kivymd.color_definitions import colors, text_colors

    for c in colors.items():
        if c[0] in ["Light", "Dark"]:
            continue
        color = c[0]
        print(f"For the {color} color palette:")
        for name, hex_color in c[1].items():
            if hex_color:
                col = get_color_from_hex(hex_color)
                col_bri = get_contrast_text_color(col)
                con_rat = get_contrast_text_color(col, use_color_brightness=False)
                text_color = text_colors[c[0]][name]
                print(
                    f"   The {name} hue gives {col_bri} using color "
                    f"brightness, {con_rat} using contrast ratio, and "
github HeaTTheatR / KivyMD / kivymd / uix / picker.py View on Github external
def rgb_hex(self, col):
        return get_color_from_hex(colors[col][self.theme_cls.accent_hue])
github Joelzeller / CoPilot / kivymd / theming.py View on Github external
def _get_error_color(self):
        return get_color_from_hex(colors['Red']['A700'])
github AndreMiras / KivyMD / kivymd / theme_picker.py View on Github external
def rgb_hex(self, col):
        return get_color_from_hex(colors[col][self.theme_cls.accent_hue])
github Joelzeller / CoPilot / kivymd / theme_picker.py View on Github external
def rgb_hex(self, col):
        return get_color_from_hex(colors[col][self.theme_cls.accent_hue])
github mobile-insight / mobileinsight-mobile / app / kivymd / theming_dynamic_text.py View on Github external
def get_contrast_text_color(color, use_color_brightness=True):
    if use_color_brightness:
        contrast_color = _black_or_white_by_color_brightness(color)
    else:
        contrast_color = _black_or_white_by_contrast_ratio(color)
    if contrast_color == 'white':
        return 1, 1, 1, 1
    else:
        return 0, 0, 0, 1

if __name__ == '__main__':
    from kivy.utils import get_color_from_hex
    from kivymd.color_definitions import colors, text_colors
    for c in list(colors.items()):
        if c[0] in ['Light', 'Dark']:
            continue
        print(("For the {} color palette:".format(c[0])))
        for name, hex_color in list(c[1].items()):
            if hex_color:
                col = get_color_from_hex(hex_color)
                col_bri = get_contrast_text_color(col)
                con_rat = get_contrast_text_color(col, use_color_brightness=False)
                text_color = text_colors[c[0]][name]
                print(("   The {} hue gives {} using color brightness, {} using contrast ratio, and {} from the MD spec"
                      .format(name, col_bri, con_rat, text_color)))
github AndreMiras / KivyMD / kivymd / slider.py View on Github external
def _set_colors(self, *args):
        if self.theme_cls.theme_style == 'Dark':
            self._track_color_normal = get_color_from_hex('FFFFFF')
            self._track_color_normal[3] = .3
            self._track_color_active = self._track_color_normal
            self._track_color_disabled = self._track_color_normal
            self.thumb_color = get_color_from_hex(colors['Grey']['400'])
            self.thumb_color_down = get_color_from_hex(colors[self.theme_cls.primary_palette]['200'])
            self.thumb_color_disabled = get_color_from_hex(colors['Grey']['800'])
        else:
            self._track_color_normal = get_color_from_hex('000000')
            self._track_color_normal[3] = 0.26
            self._track_color_active = get_color_from_hex('000000')
            self._track_color_active[3] = 0.38
            self._track_color_disabled = get_color_from_hex('000000')
            self._track_color_disabled[3] = 0.26
            self.thumb_color_down = self.theme_cls.primary_color