def __init__(self, **kwargs):
     super().__init__(**kwargs)
     if self.button_text != "":
         button = MDFlatButton(text=self.button_text)
         self.ids.box.add_widget(button)
         if self.button_callback:
             button.bind(on_release=self.button_callback)
Exemple #2
0
 def show_dialog(self, *args):
     button = MDFlatButton(text='OK')
     self.dialog = MDDialog(size_hint=(0.5, 0.4),
                            auto_dismiss=False,
                            pos_hint={"center_x": 0.5},
                            title="Material to be returned",
                            content=button)
     button.bind(on_press=self.dialog.dismiss)
     self.dialog.open()
Exemple #3
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)
Exemple #4
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)
Exemple #5
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)