Exemple #1
0
 def on_theme_text_color(self, instance, value):
     t = self.theme_cls
     op = self.opposite_colors
     setter = self.setter('color')
     t.unbind(**self._currently_bound_property)
     attr_name = {
         'Primary': 'text_color' if not op else 'opposite_text_color',
         'Secondary': 'secondary_text_color'
         if not op else 'opposite_secondary_text_color',
         'Hint': 'disabled_hint_text_color'
         if not op else 'opposite_disabled_hint_text_color',
         'Error': 'error_color',
     }.get(value, None)
     if attr_name:
         c = {attr_name: setter}
         t.bind(**c)
         self._currently_bound_property = c
         self.color = getattr(t, attr_name)
     else:
         # 'Custom' and 'ContrastParentBackground' lead here, as well as the
         # generic None value it's not yet been set
         if value == 'Custom' and self.text_color:
             self.color = self.text_color
         elif value == 'ContrastParentBackground' and self.parent_background:
             self.color = get_contrast_text_color(self.parent_background)
         else:
             self.color = [0, 0, 0, 1]
Exemple #2
0
 def on_theme_text_color(self, instance, value):
     t = self.theme_cls
     op = self.opposite_colors
     setter = self.setter('color')
     t.unbind(**self._currently_bound_property)
     attr_name = {'Primary': 'text_color' if not op else
                             'opposite_text_color',
                  'Secondary': 'secondary_text_color' if not op else
                               'opposite_secondary_text_color',
                  'Hint': 'disabled_hint_text_color' if not op else
                          'opposite_disabled_hint_text_color',
                  'Error': 'error_color',
                 }.get(value, None)
     if attr_name:
         c = {attr_name: setter}
         t.bind(**c)
         self._currently_bound_property = c
         self.color = getattr(t, attr_name)
     else:
         # 'Custom' and 'ContrastParentBackground' lead here, as well as the
         # generic None value it's not yet been set
         if value == 'Custom' and self.text_color:
             self.color = self.text_color
         elif value == 'ContrastParentBackground' and self.parent_background:
             self.color = get_contrast_text_color(self.parent_background)
         else:
             self.color = [0, 0, 0, 1]
Exemple #3
0
 def on_theme_text_color(self, instance, value):
     t = self.theme_cls
     op = self.opposite_colors
     setter = self.setter("color")
     t.unbind(**self._currently_bound_property)
     attr_name = {
         "Primary": "text_color" if not op else "opposite_text_color",
         "Secondary": "secondary_text_color"
         if not op else "opposite_secondary_text_color",
         "Hint": "disabled_hint_text_color"
         if not op else "opposite_disabled_hint_text_color",
         "Error": "error_color",
     }.get(value, None)
     if attr_name:
         c = {attr_name: setter}
         t.bind(**c)
         self._currently_bound_property = c
         self.color = getattr(t, attr_name)
     else:
         # 'Custom' and 'ContrastParentBackground' lead here, as well as the
         # generic None value it's not yet been set
         if value == "Custom" and self.text_color:
             self.color = self.text_color
         elif value == "ContrastParentBackground" and self.parent_background:
             self.color = get_contrast_text_color(self.parent_background)
         else:
             self.color = [0, 0, 0, 1]
Exemple #4
0
 def on_theme_text_color(
     self, instance_label, theme_text_color: str
 ) -> None:
     op = self.opposite_colors
     if op:
         self._text_color_str = __MDLabel_colors__.get("OP", "").get(
             theme_text_color, ""
         )
     else:
         self._text_color_str = __MDLabel_colors__.get(theme_text_color, "")
     if self._text_color_str:
         self._do_update_theme_color()
     else:
         # 'Custom' and 'ContrastParentBackground' lead here, as well as the
         # generic None value it's not yet been set
         self._text_color_str = ""
         if theme_text_color == "Custom" and self.text_color:
             self.color = self.text_color
         elif (
             theme_text_color == "ContrastParentBackground"
             and self.parent_background
         ):
             self.color = get_contrast_text_color(self.parent_background)
         else:
             self.color = [0, 0, 0, 1]