How to use the kivymd.theming.ThemableBehavior 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 Joelzeller / CoPilot / kivymd / theme_picker.py View on Github external
MDIconButton:
                        size: dp(40), dp(40)
                        size_hint: (None, None)
                        canvas:
                            Color:
                                rgba: app.theme_cls.bg_normal
                            Ellipse:
                                size: self.size
                                pos: self.pos
                        disabled: True


""")


class MDThemePicker(ThemableBehavior, FloatLayout, ModalView, ElevationBehavior):
    # background_color = ListProperty([0, 0, 0, 0])
    time = ObjectProperty()

    def __init__(self, **kwargs):
        super(MDThemePicker, self).__init__(**kwargs)

    def rgb_hex(self, col):
        return get_color_from_hex(colors[col][self.theme_cls.accent_hue])


if __name__ == "__main__":
    from kivy.app import App
    from kivymd.theming import ThemeManager

    class ThemePickerApp(App):
        theme_cls = ThemeManager()
github HeaTTheatR / KivyMD / kivymd / time_picker.py View on Github external
root.pos[0] + root.size[0] - self.width - dp(10),\
            root.pos[1] + dp(10)
        text: "OK"
        on_release: root.close_ok()

    MDFlatButton:
        id: cancel_button
        pos:
            root.pos[0] + root.size[0] - self.width - ok_button.width\
            - dp(10), root.pos[1] + dp(10)
        text: "Cancel"
        on_release: root.close_cancel()
''')


class MDTimePicker(ThemableBehavior, FloatLayout, ModalView,
                   RectangularElevationBehavior):
    time = ObjectProperty()

    def __init__(self, **kwargs):
        super(MDTimePicker, self).__init__(**kwargs)
        self.current_time = self.ids.time_picker.time

    def set_time(self, time):
        try:
            self.ids.time_picker.set_time(time)
        except AttributeError:
            raise TypeError(
                "MDTimePicker._set_time must receive a datetime object, "
                "not a \"" + type(time).__name__ + "\"")

    def close_cancel(self):
github HeaTTheatR / KivyMD / kivymd / uix / context_menu.py View on Github external
if self.arrow_right:
            if self.context_menu.context_submenu_open:
                return
            self.context_menu.generates_context_submenu(
                self, self.name_item_menu, self.text
            )

    def on_leave(self):
        self.background_color = self._background_color


class MenuItem(BasedMenuItem):
    pass


class MenuIconItem(BasedMenuItem, ThemableBehavior):
    icon = StringProperty("circle-outline")
    icon_color = ListProperty()
    icon_size = NumericProperty()


class MDContextMenuItem(BoxLayout, ThemableBehavior, HoverBehavior):
    """An item inside the context menu header."""

    text = StringProperty()
    """Text item"""

    color_active = ListProperty()
    """Color of the item when it is selected."""

    text_color = ListProperty()
    """Color of the item."""
github AndreMiras / KivyMD / kivymd / selectioncontrols.py View on Github external
class Thumb(CircularElevationBehavior, CircularRippleBehavior, ButtonBehavior,
            Widget):
    ripple_scale = NumericProperty(2)

    def _set_ellipse(self, instance, value):
        self.ellipse.size = (self.ripple_rad, self.ripple_rad)
        if self.ellipse.size[0] > self.width * 1.5 and not self.fading_out:
            self.fade_out()
        self.ellipse.pos = (self.center_x - self.ripple_rad / 2.,
                            self.center_y - self.ripple_rad / 2.)
        self.stencil.pos = (
            self.center_x - (self.width * self.ripple_scale) / 2,
            self.center_y - (self.height * self.ripple_scale) / 2)


class MDSwitch(ThemableBehavior, ButtonBehavior, FloatLayout):
    active = BooleanProperty(False)

    _thumb_color = ListProperty(get_color_from_hex(colors['Grey']['50']))

    def _get_thumb_color(self):
        return self._thumb_color

    def _set_thumb_color(self, color, alpha=None):
        if len(color) == 2:
            self._thumb_color = get_color_from_hex(colors[color[0]][color[1]])
            if alpha:
                self._thumb_color[3] = alpha
        elif len(color) == 4:
            self._thumb_color = color

    thumb_color = AliasProperty(_get_thumb_color, _set_thumb_color,
github HeaTTheatR / KivyMD / kivymd / uix / selectioncontrol.py View on Github external
def _set_ellipse(self, instance, value):
        self.ellipse.size = (self.ripple_rad, self.ripple_rad)
        if self.ellipse.size[0] > self.width * 1.5 and not self.fading_out:
            self.fade_out()
        self.ellipse.pos = (
            self.center_x - self.ripple_rad / 2.0,
            self.center_y - self.ripple_rad / 2.0,
        )
        self.stencil.pos = (
            self.center_x - (self.width * self.ripple_scale) / 2,
            self.center_y - (self.height * self.ripple_scale) / 2,
        )


class MDSwitch(ThemableBehavior, ButtonBehavior, FloatLayout):
    active = BooleanProperty(False)

    _thumb_color = ListProperty(get_color_from_hex(colors["Gray"]["50"]))

    def _get_thumb_color(self):
        return self._thumb_color

    def _set_thumb_color(self, color, alpha=None):
        if len(color) == 2:
            self._thumb_color = get_color_from_hex(colors[color[0]][color[1]])
            if alpha:
                self._thumb_color[3] = alpha
        elif len(color) == 4:
            self._thumb_color = color

    thumb_color = AliasProperty(
github HeaTTheatR / KivyMD / kivymd / uix / useranimationcard.py View on Github external
_primary_color=self.theme_cls.primary_color, d=0.3, t="in_out_cubic"
        ).start(self.user_animation_card)
        Animation(y=self._obj_avatar.y + 30, d=0.4, t="in_out_cubic").start(
            self._obj_avatar
        )


class UserAnimationCard(ThemableBehavior, FloatLayout):
    user_name = StringProperty()
    path_to_avatar = StringProperty()
    _callback_back = ObjectProperty()
    _primary_color = ListProperty()


class ModifiedToolbar(
    ThemableBehavior, SpecificBackgroundColorBehavior, BoxLayout
):
    left_action_items = ListProperty()
    title = StringProperty()

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.bind(specific_text_color=self.update_action_bar_text_colors)
        Clock.schedule_once(
            lambda x: self.on_left_action_items(0, self.left_action_items)
        )

    def on_left_action_items(self, instance, value):
        self.update_action_bar(self.ids["left_actions"], value)

    def update_action_bar(self, action_bar, action_bar_items):
        action_bar.clear_widgets()
github AndreMiras / KivyMD / kivymd / date_picker.py View on Github external
size: (dp(40), dp(40)) if root.theme_cls.device_orientation == 'portrait'\
                else (dp(32), dp(32))
    size_hint: (None, None)
    canvas:
        Color:
            rgba: self.theme_cls.primary_color if self.shown else [0, 0, 0, 0]
        Ellipse:
            size: (dp(40), dp(40)) if root.theme_cls.device_orientation == 'portrait'\
                else (dp(32), dp(32))
            pos: self.pos if root.theme_cls.device_orientation == 'portrait'\
                else [self.pos[0], self.pos[1]]
""")


class DaySelector(ThemableBehavior, AnchorLayout):
    shown = BooleanProperty(False)

    def __init__(self, parent):
        super(DaySelector, self).__init__()
        self.parent_class = parent
        self.parent_class.add_widget(self, index=7)
        self.selected_widget = None
        Window.bind(on_resize=self.move_resize)

    def update(self):
        parent = self.parent_class
        if parent.sel_month == parent.month and parent.sel_year == parent.year:
            self.shown = True
        else:
            self.shown = False
github AndreMiras / KivyMD / kivymd / navigationdrawer.py View on Github external
:class:`~kivy.uix.scrollview.ScrollView` content area.
        '''
        if issubclass(widget.__class__, BaseListItem):
            self._list.add_widget(widget, index)
            if len(self._list.children) == 1:
                widget._active = True
                self.active_item = widget
            widget.bind(on_release=lambda x: self.panel.toggle_state())
            widget.bind(on_release=lambda x: x._set_active(True, list=self))
        elif issubclass(widget.__class__, NavigationDrawerHeaderBase):
            self._header_container.add_widget(widget)
        else:
            super(MDNavigationDrawer, self).add_widget(widget, index)


class NavigationLayout(VendorNavigationDrawer, ThemableBehavior):
    '''
    The container layout that manages the :class:`MDNavigationDrawer`.
    '''
    opening_transition = StringProperty('out_sine')
    closing_transition = StringProperty('out_sine')
    min_dist_to_open = NumericProperty(0.2)
    min_dist_to_close = NumericProperty(0.8)
    anim_time = NumericProperty(0.2)
    separator_image = StringProperty('{}'.format(images_path + '/transparent.png'))
    side_panel_positioning = 'left'
    side_panel_width = NumericProperty(dp(320))
    max_shadow_opacity = NumericProperty(0.5)
    anim_type = StringProperty('slide_above_simple')

    def __init__(self, **kwargs):
        super(NavigationLayout, self).__init__(**kwargs)
github HeaTTheatR / KivyMD / kivymd / uix / menu.py View on Github external
self.x, self.top,
                        self.x, self.y
                        )
"""
)


class MDMenuItem(RecycleDataViewBehavior, ButtonBehavior, BoxLayout):
    text = StringProperty()


class MDMenu(RecycleView):
    width_mult = NumericProperty(1)


class MDDropdownMenu(ThemableBehavior, BoxLayout):
    items = ListProperty()
    """See :attr:`~kivy.uix.recycleview.RecycleView.data`
    """

    width_mult = NumericProperty(1)
    """This number multiplied by the standard increment (56dp on mobile,
    64dp on desktop, determines the width of the menu items.

    If the resulting number were to be too big for the application Window,
    the multiplier will be adjusted for the biggest possible one.
    """

    max_height = NumericProperty()
    """The menu will grow no bigger than this number.

    Set to 0 for no limit. Defaults to 0.