How to use kivymd - 10 common examples

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 / demos / kitchen_sink / main.py View on Github external
f"for show example apps\n\n"
            f"Author - [b][color={self.hex_primary_color}]"
            f"Andrés Rodríguez[/color][/b]\n"
            f"[u][b][color={self.hex_primary_color}]"
            f"andres.rodriguez@lithersoft.com[/color][/b][/u]\n\n\n"
            f"Authors this Fork:\n\n"
            f"[b][color={self.hex_primary_color}]"
            f"Ivanov Yuri[/color][/b]\n"
            f"[u][b][color={self.hex_primary_color}]"
            f"kivydevelopment@gmail.com[/color][/b][/u]\n\n"
            f"[b][color={self.hex_primary_color}]Artem S. Bulgakov[/color][/b]\n"
            f"[u][b][color={self.hex_primary_color}]"
            f"bulgakov-a-s@yandex.ru[/color][/b][/u]\n\n"
            f"and contributors..."
        )
        self.list_name_icons = list(md_icons.keys())[0:15]
        Window.bind(on_keyboard=self.events, on_resize=self.window_resize)
        crop_image(
            (Window.width, int(dp(Window.height * 35 // 100))),
            f"{os.environ['KITCHEN_SINK_ASSETS']}guitar-1139397_1280.png",
            f"{os.environ['KITCHEN_SINK_ASSETS']}guitar-1139397_1280_crop.png",
        )
github cruor99 / sadpandareader / app / main.py View on Github external
newfilter = Filters(doujinshi=filters["doujinshi"],
                            manga=filters["manga"],
                            artistcg=filters["artistcg"],
                            gamecg=filters["gamecg"],
                            western=filters["western"],
                            nonh=filters["nonh"],
                            imageset=filters["imageset"],
                            cosplay=filters["cosplay"],
                            asianporn=filters["asianporn"],
                            misc=filters["misc"])
        db.add(newfilter)
        db.commit()


class SadpandaApp(App):
    theme_cls = ThemeManager()
    nav_drawer = ObjectProperty()

    def __init__(self, **kwargs):
        super(SadpandaApp, self).__init__(**kwargs)
        Logger.info(sys.path)
        Window.bind(on_keyboard=self.onBackBtn)
        #Window.softinput_mode = "below_target"
        data_dir = getattr(self, "user_data_dir")
        self.data_dir = data_dir
        # defaultdir = Config.getdefault("kivy", "log_dir", data_dir)
        # if defaultdir == data_dir:
        #    pass
        # else:
        #    Config.set("kivy", "log_dir", data_dir)
        #    Config.set("kivy", "log_enable", 1)
        #    Config.set("kivy", "log_level", "debug")
github AndreMiras / EtherollApp / src / etherollapp / etheroll / roll_results.py View on Github external
from kivy.app import App
from kivy.clock import Clock, mainthread
from kivy.properties import ListProperty
from kivymd.label import MDLabel
from kivymd.list import ILeftBody, ThreeLineAvatarListItem
from pyetheroll.constants import ROUND_DIGITS

from etherollapp.etheroll.ui_utils import Dialog, SubScreen, load_kv_from_py
from etherollapp.etheroll.utils import run_in_thread

load_kv_from_py(__file__)


class DiceResultWidget(ILeftBody, MDLabel):
    pass


class RollResultsScreen(SubScreen):

    roll_logs = ListProperty()

    def __init__(self, **kwargs):
        super(RollResultsScreen, self).__init__(**kwargs)
        # TODO: make it a property that starts/stops spinner on set
        self._fetching_results = False
        Clock.schedule_once(self._after_init)

    def _after_init(self, dt):
        """
        Binds events.
github HeaTTheatR / KivyMD / kivymd / uix / tab.py View on Github external
def switch_tabs_to_text(self, istance_android_tabs):
            for instance_tab in istance_android_tabs.ids.scrollview.children[
                0
            ].children:
                for k, v in md_icons.items():
                    if v == instance_tab.text:
                        istance_android_tabs.ids.scrollview.children[0].remove_widget(
                            instance_tab
                        )
                        istance_android_tabs.add_widget(
                            MyTab(text=" ".join(k.split("-")).capitalize())
                        )
                        break
github HeaTTheatR / KivyMD / kivymd / uix / tab.py View on Github external
def switch_tabs_to_text(self, istance_android_tabs):
            for instance_tab in istance_android_tabs.ids.scrollview.children[
                0
            ].children:
                for k, v in md_icons.items():
                    if v == instance_tab.text:
                        istance_android_tabs.ids.scrollview.children[
                            0
                        ].remove_widget(instance_tab)
                        istance_android_tabs.add_widget(
                            MyTab(text=" ".join(k.split("-")).capitalize())
                        )
                        break
github HeaTTheatR / KivyMD / demos / kitchen_sink / libs / baseclass / tabs.py View on Github external
def switch_tabs_to_text(self, istance_android_tabs):
        for instance_tab in istance_android_tabs.ids.scrollview.children[
            0
        ].children:
            for k, v in md_icons.items():
                if v == instance_tab.text:
                    istance_android_tabs.ids.scrollview.children[
                        0
                    ].remove_widget(instance_tab)
                    istance_android_tabs.add_widget(
                        Factory.KitchenSinkTabItem(
                            text=" ".join(k.split("-")).capitalize()
                        )
                    )
                    break
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,