CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-kivymd

Set of widgets for Kivy inspired by Google's Material Design

Pending
Overview
Eval results
Files

dialogs.mddocs/

Dialogs & Overlays

Dialog and overlay components for presenting focused content, actions, and information that appears above the main interface. These components include dialogs, bottom sheets, menus, snackbars, and tooltips that follow Material Design interaction patterns.

Capabilities

Dialogs

Modal dialogs for presenting focused content and actions to users.

class BaseDialog:
    """
    Base class for dialog implementations.
    
    Foundation class providing common dialog functionality and styling.
    """
    auto_dismiss: bool  # Dismiss dialog when touching outside
    
    def open(self):
        """Open the dialog."""
        
    def dismiss(self):
        """Close the dialog."""

class MDDialog:
    """
    Material Design dialog.
    
    Modal dialog for displaying focused content, confirmations, or forms
    with Material Design styling and animations.
    """
    # Content
    title: str  # Dialog title text
    text: str   # Dialog body text
    buttons: list  # List of dialog action buttons
    items: list    # List of dialog items (alternative to text)
    
    # Visual styling
    md_bg_color: str | list  # Background color
    elevation: float  # Dialog elevation
    radius: list     # Corner radius
    
    # Sizing and positioning
    size_hint: tuple  # Dialog size hint
    auto_dismiss: bool  # Auto dismiss on outside touch
    
    # Callbacks
    def on_open(self):
        """Called when dialog opens."""
        
    def on_dismiss(self):
        """Called when dialog is dismissed."""

Bottom Sheets

Bottom sheets that slide up from the bottom to present additional content or actions.

class MDBottomSheet:
    """
    Base Material Design bottom sheet.
    
    Container that slides up from the bottom of the screen to display
    additional content or actions.
    """
    animation: bool  # Enable open/close animations
    duration_opening: float  # Opening animation duration
    duration_closing: float  # Closing animation duration
    
    # Behavior
    auto_dismiss: bool  # Auto dismiss when touching outside
    
    def open(self):
        """Open the bottom sheet."""
        
    def dismiss(self):
        """Close the bottom sheet."""

class MDCustomBottomSheet:
    """
    Custom Material Design bottom sheet.
    
    Bottom sheet with custom content that can contain any widgets.
    """
    screen: object  # Screen content to display
    
class MDListBottomSheet:
    """
    List-style Material Design bottom sheet.
    
    Bottom sheet that displays a list of selectable items.
    """
    sheet_list: list  # List of sheet items
    
    def add_item(self, text: str, callback=None):
        """
        Add item to bottom sheet.
        
        Args:
            text (str): Item text
            callback: Function to call when item is selected
        """

class MDGridBottomSheet:
    """
    Grid-style Material Design bottom sheet.
    
    Bottom sheet that displays items in a grid layout.
    """
    sheet_list: list  # List of sheet items with icons
    
class GridBottomSheetItem:
    """
    Grid item for grid bottom sheet.
    
    Individual item in a grid bottom sheet with icon and text.
    """
    text: str  # Item text
    icon: str  # Item icon from md_icons
    
    def on_release(self):
        """Called when item is selected."""

Menus

Dropdown and context menus for presenting lists of actions or options.

class MDDropdownMenu:
    """
    Material Design dropdown menu.
    
    Floating menu that appears below or above its caller, containing
    a list of selectable actions or options.
    """
    # Menu items
    items: list  # List of menu items: [{"text": "...", "icon": "...", "on_release": callback}, ...]
    
    # Positioning
    caller: object  # Widget that triggers the menu
    position: str   # Menu position: "bottom", "top", "center", "auto"
    
    # Sizing
    width_mult: float  # Width multiplier relative to caller
    max_height: str    # Maximum menu height (e.g., "200dp")
    
    # Visual styling
    elevation: float   # Menu elevation
    radius: list       # Corner radius
    
    # Behavior
    auto_dismiss: bool  # Auto dismiss when item selected
    
    def open(self):
        """Open the dropdown menu."""
        
    def dismiss(self):
        """Close the dropdown menu."""
        
    def check_position_caller(self, caller):
        """
        Check and adjust menu position relative to caller.
        
        Args:
            caller: Widget that triggered the menu
        """

Snackbars

Temporary messages that appear at the bottom of the screen.

class BaseSnackbar:
    """
    Base snackbar implementation.
    
    Foundation class for snackbar functionality.
    """
    snackbar_animation_dir: str  # Animation direction
    
class Snackbar:
    """
    Material Design snackbar.
    
    Brief message that appears temporarily at the bottom of the screen
    to provide feedback about an operation.
    """
    text: str  # Snackbar message text
    snackbar_x: str    # X position (e.g., "10dp")
    snackbar_y: str    # Y position (e.g., "10dp") 
    size_hint_x: float # Width size hint
    
    # Action button
    button_text: str     # Action button text
    button_callback: object  # Action button callback
    
    # Visual styling
    bg_color: str | list    # Background color
    buttons_color: str | list  # Button text color
    
    # Timing
    duration: float  # Display duration in seconds
    
    def open(self):
        """Show the snackbar."""
        
    def dismiss(self):
        """Hide the snackbar."""

Tooltips

Hover tooltips that provide additional information about UI elements.

class MDTooltip:
    """
    Material Design tooltip behavior.
    
    Mixin behavior that adds tooltip functionality to widgets.
    Displays informational text when hovering over the widget.
    """
    tooltip_text: str  # Tooltip text content
    tooltip_font_size: str  # Tooltip font size (e.g., "14sp")
    tooltip_radius: list    # Tooltip corner radius
    tooltip_bg_color: str | list  # Tooltip background color
    tooltip_text_color: str | list  # Tooltip text color
    
    # Positioning
    tooltip_pos_x: float  # X offset from widget
    tooltip_pos_y: float  # Y offset from widget
    
    # Timing
    tooltip_display_delay: float  # Delay before showing tooltip
    tooltip_hide_delay: float     # Delay before hiding tooltip
    
    def display_tooltip(self):
        """Display the tooltip."""
        
    def hide_tooltip(self):
        """Hide the tooltip."""

class MDTooltipViewClass:
    """
    Tooltip view implementation.
    
    The visual tooltip widget that contains the tooltip content.
    """
    tooltip_text: str  # Tooltip text
    
    # Visual properties
    md_bg_color: str | list  # Background color
    radius: list  # Corner radius
    elevation: float  # Tooltip elevation

Usage Examples

Basic Dialog

from kivymd.uix.dialog import MDDialog
from kivymd.uix.button import MDFlatButton, MDRaisedButton

class MyApp(MDApp):
    def show_dialog(self):
        # Create dialog buttons
        close_button = MDFlatButton(
            text="CANCEL",
            on_release=self.close_dialog
        )
        
        confirm_button = MDRaisedButton(
            text="CONFIRM",
            on_release=self.confirm_action
        )
        
        # Create dialog
        self.dialog = MDDialog(
            title="Confirm Action",
            text="Are you sure you want to delete this item? This action cannot be undone.",
            buttons=[close_button, confirm_button],
            size_hint=(0.8, None),
            height="200dp"
        )
        
        self.dialog.open()
    
    def close_dialog(self, instance):
        """Close dialog without action."""
        self.dialog.dismiss()
    
    def confirm_action(self, instance):
        """Handle confirmation."""
        print("Action confirmed")
        self.dialog.dismiss()

Bottom Sheet Menu

from kivymd.uix.bottomsheet import MDListBottomSheet

class MyApp(MDApp):
    def show_bottom_sheet(self):
        # Create bottom sheet
        bottom_sheet = MDListBottomSheet()
        
        # Add menu items
        menu_items = [
            ("Share", "share"),
            ("Copy Link", "content-copy"),
            ("Edit", "pencil"),
            ("Delete", "delete"),
            ("Archive", "archive")
        ]
        
        for text, icon in menu_items:
            bottom_sheet.add_item(
                text=text,
                callback=lambda x, action=text: self.handle_action(action)
            )
        
        bottom_sheet.open()
    
    def handle_action(self, action):
        """Handle bottom sheet action."""
        print(f"Action selected: {action}")

Dropdown Menu

from kivymd.uix.menu import MDDropdownMenu
from kivymd.uix.button import MDRaisedButton

class MyApp(MDApp):
    def build(self):
        # Menu trigger button
        self.menu_button = MDRaisedButton(
            text="Open Menu",
            pos_hint={"center_x": 0.5, "center_y": 0.5},
            on_release=self.open_menu
        )
        
        # Create dropdown menu
        menu_items = [
            {
                "text": "New File",
                "icon": "file-plus",
                "on_release": lambda: self.menu_callback("New File")
            },
            {
                "text": "Open File", 
                "icon": "folder-open",
                "on_release": lambda: self.menu_callback("Open File")
            },
            {
                "text": "Save File",
                "icon": "content-save",
                "on_release": lambda: self.menu_callback("Save File")
            },
            {
                "text": "Settings",
                "icon": "cog",
                "on_release": lambda: self.menu_callback("Settings")
            }
        ]
        
        self.menu = MDDropdownMenu(
            caller=self.menu_button,
            items=menu_items,
            width_mult=4,
            position="bottom"
        )
        
        return self.menu_button
    
    def open_menu(self, instance):
        """Open dropdown menu."""
        self.menu.open()
    
    def menu_callback(self, action):
        """Handle menu item selection."""
        print(f"Menu item selected: {action}")
        self.menu.dismiss()

Snackbar Notifications

from kivymd.uix.snackbar import Snackbar

class MyApp(MDApp):
    def show_snackbar(self, message, action_text=None, action_callback=None):
        """Show snackbar notification."""
        snackbar = Snackbar(
            text=message,
            snackbar_x="10dp",
            snackbar_y="10dp",
            size_hint_x=0.9,
            duration=3.0
        )
        
        # Add action button if provided
        if action_text and action_callback:
            snackbar.button_text = action_text
            snackbar.button_callback = action_callback
        
        snackbar.open()
    
    def handle_save(self):
        """Example save action with snackbar feedback."""
        # Simulate save operation
        success = True
        
        if success:
            self.show_snackbar(
                "File saved successfully",
                "UNDO",
                self.undo_save
            )
        else:
            self.show_snackbar("Error saving file")
    
    def undo_save(self, instance):
        """Handle undo action."""
        print("Save undone")
        self.show_snackbar("Save undone")

Custom Dialog with Form

from kivymd.uix.dialog import MDDialog
from kivymd.uix.textfield import MDTextField
from kivymd.uix.button import MDFlatButton, MDRaisedButton
from kivymd.uix.boxlayout import MDBoxLayout

class MyApp(MDApp):
    def show_form_dialog(self):
        # Create form content
        content = MDBoxLayout(
            orientation="vertical",
            spacing="16dp",
            adaptive_height=True,
            padding="16dp"
        )
        
        # Form fields
        self.name_field = MDTextField(
            hint_text="Enter name",
            required=True,
            mode="rectangle"
        )
        
        self.email_field = MDTextField(
            hint_text="Enter email",
            mode="rectangle"
        )
        
        content.add_widget(self.name_field)
        content.add_widget(self.email_field)
        
        # Dialog buttons
        cancel_button = MDFlatButton(
            text="CANCEL",
            on_release=self.close_form_dialog
        )
        
        submit_button = MDRaisedButton(
            text="SUBMIT",
            on_release=self.submit_form
        )
        
        # Create dialog
        self.form_dialog = MDDialog(
            title="Add Contact",
            type="custom",
            content_cls=content,
            buttons=[cancel_button, submit_button],
            size_hint=(0.8, None),
            height="300dp"
        )
        
        self.form_dialog.open()
    
    def close_form_dialog(self, instance):
        """Close form dialog."""
        self.form_dialog.dismiss()
    
    def submit_form(self, instance):
        """Handle form submission."""
        name = self.name_field.text
        email = self.email_field.text
        
        if name.strip():
            print(f"Contact added: {name}, {email}")
            self.form_dialog.dismiss()
            self.show_snackbar("Contact added successfully")
        else:
            self.name_field.error = True
            self.name_field.helper_text = "Name is required"

Tooltip Usage

from kivymd.uix.button import MDIconButton
from kivymd.uix.tooltip import MDTooltip

class TooltipButton(MDIconButton, MDTooltip):
    """Icon button with tooltip."""
    pass

class MyApp(MDApp):
    def build(self):
        # Create button with tooltip
        tooltip_button = TooltipButton(
            icon="information",
            tooltip_text="This button provides helpful information",
            pos_hint={"center_x": 0.5, "center_y": 0.5}
        )
        
        return tooltip_button

Install with Tessl CLI

npx tessl i tessl/pypi-kivymd

docs

advanced.md

animations.md

application.md

buttons.md

dialogs.md

index.md

layouts.md

lists.md

navigation.md

text-input.md

tile.json