Ejemplo n.º 1
0
    def add_action_button(self, text, action=None):
        """Add an :class:`FlatButton` to the right of the action area.

        :param icon: Unicode character for the icon
        :type icon: str or None
        :param action: Function set to trigger when on_release fires
        :type action: function or None
        """
        button = MDFlatButton(text=text, size_hint=(None, None), height=dp(36))
        if action:
            button.bind(on_release=action)
        button.text_color = self.theme_cls.primary_color
        button.md_bg_color = self.theme_cls.bg_light
        self._action_buttons.append(button)
Ejemplo n.º 2
0
    def add_action_button(self, text, action=None):
        """Add an :class:`FlatButton` to the right of the action area.

        :param icon: Unicode character for the icon
        :type icon: str or None
        :param action: Function set to trigger when on_release fires
        :type action: function or None
        """
        button = MDFlatButton(text=text,
                              size_hint=(None, None),
                              height=dp(36))
        if action:
            button.bind(on_release=action)
        button.text_color = self.theme_cls.primary_color
        button.background_color = self.theme_cls.bg_light
        self._action_buttons.append(button)
Ejemplo n.º 3
0
    def add_action_button(self, text, action=None, **kwargs):
        """Add an :class:`FlatButton` to the right of the action area.

        :param icon: Unicode character for the icon
        :type icon: str or None
        :param action: Function set to trigger when on_release fires
        :type action: function or None
        """
        def check_validation(content, *args):
            from kivymd.textfields import MDTextField, MDSelect
            try:
                for child in content.children:
                    if isinstance(child, MDSelect) or isinstance(
                            child, MDTextField):
                        if child.error:
                            self.invalid = True
                            continue
                        else:
                            self.invalid = False
                    else:
                        check_validation(child)
            except Exception as e:
                print("Exception while validate dialog Error:", str(e))
            button.disabled = self.invalid

        text_color = kwargs.get('text_color')

        button = MDFlatButton(text=text,
                              size_hint=(None, None),
                              theme_text_color="Custom",
                              height=dp(36))
        if action:
            button.bind(on_release=action)
        button.text_color = text_color if text_color else self.theme_cls.primary_color
        if kwargs.get('validate') and kwargs.get('content'):
            from kivy.clock import Clock
            from functools import partial
            self.validation_clock = Clock.schedule_interval(
                partial(check_validation, kwargs.get('content')), 0.5)

        self._action_buttons.append(button)