Kivymd PDF
Kivymd PDF
Kivymd PDF
Release 0.104.2.dev0
1 KivyMD 1
2 Contents 3
2.1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.4 Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
2.5 Change Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
2.6 About . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
2.7 KivyMD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
Index 281
i
ii
CHAPTER
ONE
KIVYMD
Is a collection of Material Design compliant widgets for use with, Kivy cross-platform graphical framework a frame-
work for cross-platform, touch-enabled graphical applications. The project’s goal is to approximate Google’s Material
Design spec as close as possible without sacrificing ease of use or application performance.
This library is a fork of the KivyMD project the author of which stopped supporting this project three years ago. We
found the strength and brought this project to a new level. Currently we’re in beta status, so things are changing all
the time and we cannot promise any kind of API stability. However it is safe to vendor now and make use of what’s
currently available.
Join the project! Just fork the project, branch out and submit a pull request when your patch is ready. If any changes
are necessary, we’ll guide you through the steps that need to be done via PR comments or access to your for may
be requested to outright submit them. If you wish to become a project developer (permission to create branches on
the project without forking for easier collaboration), have at least one PR approved and ask for it. If you contribute
regularly to the project the role may be offered to you without asking too.
1
KivyMD, Release 0.104.2.dev0
2 Chapter 1. KivyMD
CHAPTER
TWO
CONTENTS
In order to start using KivyMD, you must first install the Kivy framework on your computer. Once you have installed
Kivy, you can install KivyMD.
Warning: KivyMD depends on Kivy! Therefore, before using KivyMD, first learn how to work with Kivy.
2.1.1 Installation
_Speed Tip_: If you don’t need full commit history (about 320 MiB), you can use a shallow clone (git clone
https://github.com/kivymd/KivyMD.git –depth 1) to save time. If you need full commit history, then remove –depth 1.
class MainApp(MDApp):
def build(self):
return MDLabel(text="Hello, World", halign="center")
MainApp().run()
3
KivyMD, Release 0.104.2.dev0
class MainApp(App):
def build(self):
return Label(text="Hello, World")
MainApp().run()
At first glance, the KivyMD example contains more code. . . However, the following example already demonstrates
how difficult it is to create a custom button in Kivy:
KV = """
<RectangleFlatButton>:
ripple_color: 0, 0, 0, .2
background_color: 0, 0, 0, 0
color: root.primary_color
canvas.before:
Color:
rgba: root.primary_color
Line:
width: 1
rectangle: (self.x, self.y, self.width, self.height)
4 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
class MainApp(App):
def build(self):
screen = Builder.load_string(KV)
screen.add_widget(
RectangleFlatButton(
text="Hello, World",
pos_hint={"center_x": 0.5, "center_y": 0.5},
size_hint=(None, None),
size=(dp(110), dp(35)),
ripple_color=(0.8, 0.8, 0.8, 0.5),
)
)
return screen
MainApp().run()
class MainApp(MDApp):
def build(self):
screen = Screen()
screen.add_widget(
MDRectangleFlatButton(
text="Hello, World",
pos_hint={"center_x": 0.5, "center_y": 0.5},
)
)
return screen
MainApp().run()
2.2 Themes
2.2.1 Theming
See also:
Material Design spec, Material theming
Material App
The main class of your application, which in Kivy inherits from the App class, in KivyMD must inherit from the MDApp
class. The MDApp class has properties that allow you to control application properties such as color/style/font
of interface elements and much more.
The main application class inherited from the MDApp class has the theme_cls attribute, with which you control the
material properties of your application.
6 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
API - kivymd.theming
class kivymd.theming.ThemeManager(**kwargs)
primary_palette
The name of the color scheme that the application will use. All major material components will have the
color of the specified color theme.
Available options are: ‘Red’, ‘Pink’, ‘Purple’, ‘DeepPurple’, ‘Indigo’, ‘Blue’, ‘LightBlue’, ‘Cyan’, ‘Teal’,
‘Green’, ‘LightGreen’, ‘Lime’, ‘Yellow’, ‘Amber’, ‘Orange’, ‘DeepOrange’, ‘Brown’, ‘Gray’, ‘BlueGray’.
To change the color scheme of an application:
class MainApp(MDApp):
def build(self):
self.theme_cls.primary_palette = "Green" # "Purple", "Red"
screen = Screen()
screen.add_widget(
MDRectangleFlatButton(
text="Hello, World",
pos_hint={"center_x": 0.5, "center_y": 0.5},
)
)
return screen
MainApp().run()
2.2. Themes 7
KivyMD, Release 0.104.2.dev0
class MainApp(MDApp):
def build(self):
self.theme_cls.primary_palette = "Green" # "Purple", "Red"
self.theme_cls.primary_hue = "200" # "500"
screen = Screen()
screen.add_widget(
MDRectangleFlatButton(
text="Hello, World",
pos_hint={"center_x": 0.5, "center_y": 0.5},
)
)
return screen
MainApp().run()
8 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
KV = '''
Screen:
MDRaisedButton:
text: "primary_light"
pos_hint: {"center_x": 0.5, "center_y": 0.7}
md_bg_color: app.theme_cls.primary_light
MDRaisedButton:
text: "primary_color"
pos_hint: {"center_x": 0.5, "center_y": 0.5}
MDRaisedButton:
text: "primary_dark"
pos_hint: {"center_x": 0.5, "center_y": 0.3}
md_bg_color: app.theme_cls.primary_dark
'''
class MainApp(MDApp):
def build(self):
self.theme_cls.primary_palette = "Green"
return Builder.load_string(KV)
MainApp().run()
2.2. Themes 9
KivyMD, Release 0.104.2.dev0
primary_light is an AliasProperty that returns the value of the current application theme (in
lighter color), property is readonly.
primary_dark
Colors of the current application color theme in rgba format (in darker color).
primary_dark is an AliasProperty that returns the value of the current application theme (in
darker color), property is readonly.
accent_palette
The application color palette used for items such as the tab indicator in the MDTabsBar class and so on. . .
The image below shows the color schemes with the values self.theme_cls.accent_palette =
'Blue', Red' and Yellow':
10 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
class MainApp(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark" # "Light"
screen = Screen()
screen.add_widget(
MDRectangleFlatButton(
text="Hello, World",
pos_hint={"center_x": 0.5, "center_y": 0.5},
)
)
return screen
MainApp().run()
KV = '''
<Box@BoxLayout>:
bg: 0, 0, 0, 0
canvas:
Color:
rgba: root.bg
Rectangle:
pos: self.pos
size: self.size
BoxLayout:
Box:
bg: app.theme_cls.bg_light
Box:
(continues on next page)
2.2. Themes 11
KivyMD, Release 0.104.2.dev0
class MainApp(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark" # "Light"
return Builder.load_string(KV)
MainApp().run()
bg_darkest is an AliasProperty that returns the value in rgba format for bg_darkest, property
is readonly.
opposite_bg_darkest
The opposite value of color in the bg_darkest.
opposite_bg_darkest is an AliasProperty that returns the value in rgba format for
opposite_bg_darkest, property is readonly.
bg_dark
Similar to bg_normal, but the color values are one tone lower (darker) than bg_normal.
bg_dark is an AliasProperty that returns the value in rgba format for bg_dark, property is
readonly.
opposite_bg_dark
The opposite value of color in the bg_dark.
opposite_bg_dark is an AliasProperty that returns the value in rgba format for
opposite_bg_dark, property is readonly.
12 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
bg_normal
Similar to bg_light, but the color values are one tone lower (darker) than bg_light.
bg_normal is an AliasProperty that returns the value in rgba format for bg_normal, property
is readonly.
opposite_bg_normal
The opposite value of color in the bg_normal.
opposite_bg_normal is an AliasProperty that returns the value in rgba format for
opposite_bg_normal, property is readonly.
bg_light
” Depending on the style of the theme (‘Dark’ or ‘Light’) that the application uses, bg_light contains
the color value in rgba format for the widgets background.
bg_light is an AliasProperty that returns the value in rgba format for bg_light, property is
readonly.
opposite_bg_light
The opposite value of color in the bg_light.
opposite_bg_light is an AliasProperty that returns the value in rgba format for
opposite_bg_light, property is readonly.
divider_color
Color for dividing lines such as MDSeparator.
divider_color is an AliasProperty that returns the value in rgba format for divider_color,
property is readonly.
opposite_divider_color
The opposite value of color in the divider_color.
opposite_divider_color is an AliasProperty that returns the value in rgba format for
opposite_divider_color, property is readonly.
text_color
Color of the text used in the MDLabel.
text_color is an AliasProperty that returns the value in rgba format for text_color, property
is readonly.
opposite_text_color
The opposite value of color in the text_color.
opposite_text_color is an AliasProperty that returns the value in rgba format for
opposite_text_color, property is readonly.
secondary_text_color
The color for the secondary text that is used in classes from the module TwoLineListItem.
secondary_text_color is an AliasProperty that returns the value in rgba format for
secondary_text_color, property is readonly.
opposite_secondary_text_color
The opposite value of color in the secondary_text_color.
opposite_secondary_text_color is an AliasProperty that returns the value in rgba format
for opposite_secondary_text_color, property is readonly.
icon_color
Color of the icon used in the MDIconButton.
2.2. Themes 13
KivyMD, Release 0.104.2.dev0
icon_color is an AliasProperty that returns the value in rgba format for icon_color, property
is readonly.
opposite_icon_color
The opposite value of color in the icon_color.
opposite_icon_color is an AliasProperty that returns the value in rgba format for
opposite_icon_color, property is readonly.
disabled_hint_text_color
Color of the disabled text used in the MDTextField.
disabled_hint_text_color is an AliasProperty that returns the value in rgba format for
disabled_hint_text_color, property is readonly.
opposite_disabled_hint_text_color
The opposite value of color in the disabled_hint_text_color.
opposite_disabled_hint_text_color is an AliasProperty that returns the value in rgba
format for opposite_disabled_hint_text_color, property is readonly.
error_color
Color of the error text used in the MDTextField.
error_color is an AliasProperty that returns the value in rgba format for error_color,
property is readonly.
ripple_color
Color of ripple effects.
ripple_color is an AliasProperty that returns the value in rgba format for ripple_color,
property is readonly.
device_orientation
Device orientation.
device_orientation is an StringProperty.
standard_increment
Value of standard increment.
standard_increment is an AliasProperty that returns the value in rgba format for
standard_increment, property is readonly.
horizontal_margins
Value of horizontal margins.
horizontal_margins is an AliasProperty that returns the value in rgba format for
horizontal_margins, property is readonly.
set_clearcolor
font_styles
Data of default font styles.
Add custom font:
KV = '''
Screen:
MDLabel:
text: "JetBrainsMono"
halign: "center"
(continues on next page)
14 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
class MainApp(MDApp):
def build(self):
LabelBase.register(
name="JetBrainsMono",
fn_regular="JetBrainsMono-Regular.ttf")
theme_font_styles.append('JetBrainsMono')
self.theme_cls.font_styles["JetBrainsMono"] = [
"JetBrainsMono",
16,
False,
0.15,
]
return Builder.load_string(KV)
MainApp().run()
font_styles is an DictProperty.
on_theme_style(self, instance, value)
set_clearcolor_by_theme_style(self, theme_style)
class kivymd.theming.ThemableBehavior(**kwargs)
theme_cls
Instance of ThemeManager class.
2.2. Themes 15
KivyMD, Release 0.104.2.dev0
theme_cls is an ObjectProperty.
device_ios
True if device is iOS.
device_ios is an BooleanProperty.
opposite_colors
This module contains MDApp class that is inherited from App. MDApp has some properties needed for KivyMD
library (like theme_cls).
You can turn on the monitor displaying the current FPS value in your application:
KV = '''
Screen:
MDLabel:
text: "Hello, World!"
halign: "center"
'''
class MainApp(MDApp):
def build(self):
return Builder.load_string(KV)
def on_start(self):
self.fps_monitor_start()
MainApp().run()
16 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
API - kivymd.app
class kivymd.app.MDApp(**kwargs)
Application class, see module documentation for more information.
Events
on_start: Fired when the application is being started (before the runTouchApp() call.
on_stop: Fired when the application stops.
on_pause: Fired when the application is paused by the OS.
on_resume: Fired when the application is resumed from pause by the OS. Beware: you have
no guarantee that this event will be fired after the on_pause event has been called.
Changed in version 1.7.0: Parameter kv_file added.
Changed in version 1.8.0: Parameters kv_file and kv_directory are now properties of App.
2.2. Themes 17
KivyMD, Release 0.104.2.dev0
theme_cls
Instance of ThemeManager class.
Warning: The theme_cls attribute is already available in a class that is inherited from the MDApp
class. The following code will result in an error!
class MainApp(MDApp):
theme_cls = ThemeManager()
theme_cls.primary_palette = "Teal"
class MainApp(MDApp):
def build(self):
self.theme_cls.primary_palette = "Teal"
theme_cls is an ObjectProperty.
See also:
Material Design spec, The color system
Material colors palette to use in kivymd.theming.ThemeManager. colors is a dict-in-dict where the first key
is a value from palette and the second key is a value from hue. Color is a hex value, a string of 6 characters (0-9,
A-F) written in uppercase.
For example, colors["Red"]["900"] is "B71C1C".
API - kivymd.color_definitions
kivymd.color_definitions.colors
Color palette. Taken from 2014 Material Design color palettes.
To demonstrate the shades of the palette, you can run the following code:
demo = '''
<Root@BoxLayout>
orientation: 'vertical'
MDToolbar:
title: app.title
18 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
ScrollView:
MDList:
id: box
<ItemColor>:
size_hint_y: None
height: "42dp"
canvas:
Color:
rgba: root.color
Rectangle:
size: self.size
pos: self.pos
MDLabel:
text: root.text
halign: "center"
<Tab>:
'''
class ItemColor(BoxLayout):
text = StringProperty()
color = ListProperty()
class Palette(MDApp):
title = "Colors definitions"
def build(self):
Builder.load_string(demo)
self.screen = Factory.Root()
2.2. Themes 19
KivyMD, Release 0.104.2.dev0
self.screen.ids.box.clear_widgets()
for value_color in colors[tab_text]:
self.screen.ids.box.add_widget(
ItemColor(
color=get_color_from_hex(colors[tab_text][value_color]),
text=value_color,
)
)
def on_start(self):
self.on_tab_switch(
None,
None,
None,
self.screen.ids.android_tabs.ids.layout.children[-1].text,
)
Palette().run()
text_colors = {}
for p in palette:
text_colors[p] = {}
for h in hue:
if h in light_colors[p]:
text_colors[p][h] = "000000"
else:
text_colors[p][h] = "FFFFFF"
20 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
See also:
Material Design Icons
List of icons from materialdesignicons.com. These expanded material design icons are maintained by Austin Andrews
(Templarian on Github).
LAST UPDATED: Version 5.5.55
To preview the icons and their names, you can use the following application:
Builder.load_string(
'''
#:import images_path kivymd.images_path
<CustomOneLineIconListItem>:
IconLeftWidget:
icon: root.icon
<PreviousMDIcons>:
BoxLayout:
orientation: 'vertical'
spacing: dp(10)
padding: dp(20)
BoxLayout:
size_hint_y: None
height: self.minimum_height
(continues on next page)
2.2. Themes 21
KivyMD, Release 0.104.2.dev0
MDIconButton:
icon: 'magnify'
MDTextField:
id: search_field
hint_text: 'Search icon'
on_text: root.set_list_md_icons(self.text, True)
RecycleView:
id: rv
key_viewclass: 'viewclass'
key_size: 'height'
RecycleBoxLayout:
padding: dp(10)
default_size: None, dp(48)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'
'''
)
class CustomOneLineIconListItem(OneLineIconListItem):
icon = StringProperty()
class PreviousMDIcons(Screen):
def add_icon_item(name_icon):
self.ids.rv.data.append(
{
"viewclass": "CustomOneLineIconListItem",
"icon": name_icon,
"text": name_icon,
"callback": lambda x: x,
}
)
self.ids.rv.data = []
for name_icon in md_icons.keys():
if search:
if text in name_icon:
add_icon_item(name_icon)
else:
add_icon_item(name_icon)
class MainApp(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = PreviousMDIcons()
(continues on next page)
22 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
def build(self):
return self.screen
def on_start(self):
self.screen.set_list_md_icons()
MainApp().run()
API - kivymd.icon_definitions
kivymd.icon_definitions.md_icons
See also:
Material Design spec, The type system
API - kivymd.font_definitions
kivymd.font_definitions.fonts
kivymd.font_definitions.theme_font_styles = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'Subtitle1
2.2. Themes 23
KivyMD, Release 0.104.2.dev0
2.3 Components
2.3.1 Spinner
Usage
KV = '''
Screen:
(continues on next page)
24 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
MDSpinner:
size_hint: None, None
size: dp(46), dp(46)
pos_hint: {'center_x': .5, 'center_y': .5}
active: True if check.active else False
MDCheckbox:
id: check
size_hint: None, None
size: dp(48), dp(48)
pos_hint: {'center_x': .5, 'center_y': .4}
active: True
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
Spinner palette
MDSpinner:
# The number of color values can be any.
palette:
[0.28627450980392155, 0.8431372549019608, 0.596078431372549, 1],
˓→[0.3568627450980392, 0.3215686274509804, 0.8666666666666667, 1],
MDSpinner(
size_hint=(None, None),
size=(dp(46), dp(46)),
pos_hint={'center_x': .5, 'center_y': .5},
active=True,
palette=[
[0.28627450980392155, 0.8431372549019608, 0.596078431372549, 1],
[0.3568627450980392, 0.3215686274509804, 0.8666666666666667, 1],
[0.8862745098039215, 0.36470588235294116, 0.592156862745098, 1],
[0.8784313725490196, 0.9058823529411765, 0.40784313725490196, 1],
]
)
2.3. Components 25
KivyMD, Release 0.104.2.dev0
API - kivymd.uix.spinner
class kivymd.uix.spinner.MDSpinner(**kwargs)
MDSpinner is an implementation of the circular progress indicator in Google’s Material Design.
It can be used either as an indeterminate indicator that loops while the user waits for something to happen, or as
a determinate indicator.
Set determinate to True to activate determinate mode, and determinate_time to set the duration of
the animation.
determinate
Determinate value.
determinate is a BooleanProperty and defaults to False.
determinate_time
Determinate time value.
determinate_time is a NumericProperty and defaults to 2.
active
Use active to start or stop the spinner.
active is a BooleanProperty and defaults to True.
color
Spinner color.
color is a ListProperty and defaults to self.theme_cls.primary_color.
palette
A set of colors. Changes with each completed spinner cycle.
palette is a ListProperty and defaults to [].
on__rotation_angle(self, *args)
on_palette(self, instance, value)
on_active(self, *args)
See also:
Material Design spec, Bottom navigation
26 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Usage
<Root>>:
MDBottomNavigation:
MDBottomNavigationItem:
name: "screen 1"
YourContent:
MDBottomNavigationItem:
name: "screen 2"
YourContent:
MDBottomNavigationItem:
name: "screen 3"
YourContent:
<Root>>:
ScreenManager:
Screen:
name: "screen 1"
YourContent:
Screen:
name: "screen 2"
YourContent:
(continues on next page)
2.3. Components 27
KivyMD, Release 0.104.2.dev0
Screen:
name: "screen 3"
YourContent:
Example
class Test(MDApp):
def build(self):
self.theme_cls.primary_palette = "Gray"
return Builder.load_string(
'''
BoxLayout:
orientation:'vertical'
MDToolbar:
title: 'Bottom navigation'
md_bg_color: .2, .2, .2, 1
specific_text_color: 1, 1, 1, 1
MDBottomNavigation:
panel_color: .2, .2, .2, 1
MDBottomNavigationItem:
name: 'screen 1'
text: 'Python'
icon: 'language-python'
MDLabel:
text: 'Python'
halign: 'center'
MDBottomNavigationItem:
name: 'screen 2'
text: 'C++'
icon: 'language-cpp'
MDLabel:
text: 'I programming of C++'
halign: 'center'
MDBottomNavigationItem:
name: 'screen 3'
text: 'JS'
icon: 'language-javascript'
MDLabel:
text: 'JS'
(continues on next page)
28 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Test().run()
__events__ = (
"on_tab_touch_down",
"on_tab_touch_move",
"on_tab_touch_up",
"on_tab_press",
"on_tab_release",
)
See also:
See __events__
Root:
MDBottomNavigation:
MDBottomNavigationItem:
on_tab_touch_down: print("on_tab_touch_down")
on_tab_touch_move: print("on_tab_touch_move")
on_tab_touch_up: print("on_tab_touch_up")
on_tab_press: print("on_tab_press")
on_tab_release: print("on_tab_release")
YourContent:
Use method switch_tab which takes as argument the name of the tab you want to switch to.
MDBottomNavigation:
text_color_active: 1, 0, 1, 1
MDBottomNavigation:
text_color_normal: 1, 0, 1, 1
2.3. Components 29
KivyMD, Release 0.104.2.dev0
See also:
See Tab auto switch example
See full example
API - kivymd.uix.bottomnavigation
class kivymd.uix.bottomnavigation.MDTab(**kwargs)
A tab is simply a screen with meta information that defines the content that goes in the tab header.
text
Tab header text.
text is an StringProperty and defaults to ‘’.
icon
Tab header icon.
icon is an StringProperty and defaults to ‘checkbox-blank-circle’.
on_tab_touch_down(self, *args)
on_tab_touch_move(self, *args)
on_tab_touch_up(self, *args)
on_tab_press(self, *args)
on_tab_release(self, *args)
class kivymd.uix.bottomnavigation.MDBottomNavigationItem(**kwargs)
A tab is simply a screen with meta information that defines the content that goes in the tab header.
header
header is an MDBottomNavigationHeader and defaults to None.
on_tab_press(self, *args)
on_leave(self, *args)
class kivymd.uix.bottomnavigation.TabbedPanelBase(**kwargs)
A class that contains all variables a TabPannel must have. It is here so I (zingballyhoo) don’t get mad about
the TabbedPannels not being DRY.
current
Current tab name.
current is an StringProperty and defaults to None.
previous_tab
previous_tab is an MDTab and defaults to None.
panel_color
Panel color of bottom navigation.
panel_color is an ListProperty and defaults to [].
tabs
30 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
class kivymd.uix.bottomnavigation.MDBottomNavigation(**kwargs)
A bottom navigation that is implemented by delegating all items to a ScreenManager.
first_widget
first_widget is an MDBottomNavigationItem and defaults to None.
tab_header
tab_header is an MDBottomNavigationHeader and defaults to None.
text_color_normal
Text color of the label when it is not selected.
text_color_normal is an ListProperty and defaults to [1, 1, 1, 1].
text_color_active
Text color of the label when it is selected.
text_color_active is an ListProperty and defaults to [1, 1, 1, 1].
on_panel_color(self, instance, value)
on_text_color_normal(self, instance, value)
on_text_color_active(self, instance, value)
switch_tab(self, name_tab)
Switching the tab by name.
refresh_tabs(self )
Refresh all tabs.
on_resize(self, instance=None, width=None, do_again=True)
Called when the application window is resized.
add_widget(self, widget, **kwargs)
Add a new widget as a child of this widget.
Parameters
widget: Widget Widget to add to our list of children.
index: int, defaults to 0 Index to insert the widget in the list. Notice that the default
of 0 means the widget is inserted at the beginning of the list and will thus be drawn
on top of other sibling widgets. For a full discussion of the index and widget hier-
archy, please see the Widgets Programming Guide.
New in version 1.0.5.
canvas: str, defaults to None Canvas to add widget’s canvas to. Can be ‘before’,
‘after’ or None for the default canvas.
New in version 1.9.0.
remove_widget(self, widget)
Remove a widget from the children of this widget.
Parameters
2.3. Components 31
KivyMD, Release 0.104.2.dev0
2.3.3 Snackbar
See also:
Material Design spec, Snackbars
Snackbars provide brief messages about app processes at the bottom of the screen.
Usage
KV = '''
#:import Snackbar kivymd.uix.snackbar.Snackbar
Screen:
MDRaisedButton:
text: "Create simple snackbar"
on_release: Snackbar(text="This is a snackbar!").show()
(continues on next page)
32 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
Snackbar(
text="This is a snackbar",
button_text="BUTTON",
button_callback=app.callback
).show()
Snackbar(
text="This is a snackbar!",
padding="20dp",
button_text="ACTION",
button_color=(1, 0, 1, 1)
).show()
Custom usage
2.3. Components 33
KivyMD, Release 0.104.2.dev0
KV = '''
Screen:
MDFloatingActionButton:
id: button
x: root.width - self.width - dp(10)
y: dp(10)
on_release: app.snackbar_show()
'''
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
self.snackbar = None
self._interval = 0
def build(self):
return self.screen
def snackbar_show(self):
if not self.snackbar:
self.snackbar = Snackbar(text="This is a snackbar!")
self.snackbar.show()
anim = Animation(y=dp(72), d=.2)
anim.bind(on_complete=lambda *args: Clock.schedule_interval(
self.wait_interval, 0))
anim.start(self.screen.ids.button)
Test().run()
34 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Custom Snackbar
KV = '''
<-Snackbar>
MDCard:
id: box
size_hint_y: None
height: dp(58)
spacing: dp(5)
padding: dp(10)
y: -self.height
x: root.padding
md_bg_color: get_color_from_hex('323232')
radius: (5, 5, 5, 5) if root.padding else (0, 0, 0, 0)
elevation: 11 if root.padding else 0
MDIconButton:
pos_hint: {'center_y': .5}
icon: root.icon
opposite_colors: True
MDLabel:
id: text_bar
size_hint_y: None
height: self.texture_size[1]
text: root.text
font_size: root.font_size
theme_text_color: 'Custom'
text_color: get_color_from_hex('ffffff')
shorten: True
shorten_from: 'right'
pos_hint: {'center_y': .5}
Screen:
MDRaisedButton:
text: "SHOW"
pos_hint: {"center_x": .5, "center_y": .45}
on_press: app.show()
'''
class CustomSnackbar(Snackbar):
icon = StringProperty()
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
(continues on next page)
2.3. Components 35
KivyMD, Release 0.104.2.dev0
def show(self):
CustomSnackbar(
text="This is a snackbar!",
icon="information",
padding="20dp",
button_text="ACTION",
button_color=(1, 0, 1, 1)
).show()
Test().run()
API - kivymd.uix.snackbar
class kivymd.uix.snackbar.Snackbar(**kwargs)
Float layout class. See module documentation for more information.
text
The text that will appear in the snackbar.
text is a StringProperty and defaults to ‘’.
font_size
The font size of the text that will appear in the snackbar.
font_size is a NumericProperty and defaults to ’15sp’.
button_text
The text that will appear in the snackbar’s button.
36 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
padding
Snackbar padding.
padding is a NumericProperty and defaults to ‘0dp’.
show(self )
Show the snackbar.
2.3.4 Banner
See also:
Material Design spec, Banner
Usage
Builder.load_string('''
<ExampleBanner@Screen>
MDBanner:
id: banner
text: ["One line string text example without actions."]
# The widget that is under the banner.
# It will be shifted down to the height of the banner.
over_widget: screen
vertical_pad: toolbar.height
MDToolbar:
id: toolbar
title: "Example Banners"
(continues on next page)
2.3. Components 37
KivyMD, Release 0.104.2.dev0
BoxLayout:
id: screen
orientation: "vertical"
size_hint_y: None
height: Window.height - toolbar.height
OneLineListItem:
text: "Banner without actions"
on_release: banner.show()
Widget:
''')
class Test(MDApp):
def build(self):
return Factory.ExampleBanner()
Test().run()
Banner type.
To use a two-line banner, specify the 'two-line' MDBanner.type for the banner and pass the list of two lines
to the MDBanner.text parameter:
MDBanner:
type: "two-line"
text:
["One line string text example without actions.", "This is the second line of
˓→the banner message."]
38 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
To add buttons to any type of banner, use the MDBanner.left_action and MDBanner.right_action pa-
rameters, which should take a list [‘Button name’, function]:
MDBanner:
text: ["One line string text example without actions."]
left_action: ["CANCEL", lambda x: None]
Or two buttons:
MDBanner:
text: ["One line string text example without actions."]
left_action: ["CANCEL", lambda x: None]
right_action: ["CLOSE", lambda x: None]
If you want to use the icon on the left in the banner, add the prefix ‘-icon’ to the banner type:
MDBanner:
type: "one-line-icon"
icon: f"{images_path}/kivymd.png"
text: ["One line string text example without actions."]
API - kivymd.uix.banner
class kivymd.uix.banner.MDBanner(**kwargs)
Widget class. See module documentation for more information.
Events
on_touch_down: (touch, ) Fired when a new touch event occurs. touch is the touch object.
on_touch_move: (touch, ) Fired when an existing touch moves. touch is the touch object.
on_touch_up: (touch, ) Fired when an existing touch disappears. touch is the touch object.
on_kv_post: (base_widget, ) Fired after all the kv rules associated with the widget and all other
widgets that are in any of those rules have had all their kv rules applied. base_widget is
the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated
from Python, e.g. MyWidget()).
Changed in version 1.11.0.
2.3. Components 39
KivyMD, Release 0.104.2.dev0
Warning: Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable
automatic garbage collection for instances of that class. This is because the Widget class creates reference
cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the EventDispatcher.
Event properties can now be used when contructing a simple class without subclassing Widget.
Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to
properties or events, as in the Kv language.
vertical_pad
Indent the banner at the top of the screen.
vertical_pad is an NumericProperty and defaults to dp(68).
opening_transition
The name of the animation transition.
opening_transition is an StringProperty and defaults to ‘in_quad’.
icon
Icon banner.
icon is an StringProperty and defaults to ‘data/logo/kivy-icon-128.png’.
over_widget
The widget that is under the banner. It will be shifted down to the height of the banner.
over_widget is an ObjectProperty and defaults to None.
text
List of lines for banner text. Must contain no more than three lines for a ‘one-line’, ‘two-line’ and ‘three-
line’ banner, respectively.
text is an ListProperty and defaults to [].
left_action
The action of banner.
To add one action, make a list [‘name_action’, callback] where ‘name_action’ is a string that corresponds
to an action name and callback is the function called on a touch release event.
left_action is an ListProperty and defaults to [].
right_action
Works the same way as left_action.
right_action is an ListProperty and defaults to [].
type
Banner type. . Available options are: (“one-line”, “two-line”, “three-line”, “one-line-icon”, “two-line-
icon”, “three-line-icon”).
type is an OptionProperty and defaults to ‘one-line’.
add_actions_buttons(self, box, data)
set_left_action(self )
set_right_action(self )
set_type_banner(self )
add_banner_to_container(self )
40 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
show(self )
animation_display_banner(self, i)
hide(self )
2.3.5 Tabs
See also:
Material Design spec, Tabs
Tabs organize content across different screens, data sets, and other interactions.
Usage
To create a tab, you must create a new class that inherits from the MDTabsBase class and the Kivy container, in which
you will create content for the tab.
class Tab(FloatLayout, MDTabsBase):
'''Class implementing content for a tab.'''
<Tab>:
MDLabel:
text: "Content"
pos_hint: {"center_x": .5, "center_y": .5}
MDTabs:
Tab:
text: "Tab 1"
(continues on next page)
2.3. Components 41
KivyMD, Release 0.104.2.dev0
Tab:
text: "Tab 1"
...
KV = '''
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "Example Tabs"
MDTabs:
id: tabs
on_tab_switch: app.on_tab_switch(*args)
<Tab>:
MDIconButton:
id: icon
icon: app.icons[0]
user_font_size: "48sp"
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Example(MDApp):
icons = list(md_icons.keys())[15:30]
def build(self):
return Builder.load_string(KV)
def on_start(self):
for name_tab in self.icons:
self.root.ids.tabs.add_widget(Tab(text=name_tab))
def on_tab_switch(
self, instance_tabs, instance_tab, instance_tab_label, tab_text
):
(continues on next page)
42 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Example().run()
Note: The MDTabsBase class has an icon parameter and, by default, tries to find the name of the icon in the file
kivymd/icon_definitions.py. If the name of the icon is not found, then the name of the tab will be plain
text, if found, the tab will look like the corresponding icon.
KV = '''
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "Example Tabs"
MDTabs:
id: tabs
on_tab_switch: app.on_tab_switch(*args)
<Tab>:
MDLabel:
id: label
text: "Tab 0"
halign: "center"
'''
2.3. Components 43
KivyMD, Release 0.104.2.dev0
def on_start(self):
for i in range(20):
self.root.ids.tabs.add_widget(Tab(text=f"Tab {i}"))
def on_tab_switch(
self, instance_tabs, instance_tab, instance_tab_label, tab_text
):
'''Called when switching tabs.
instance_tab.ids.label.text = tab_text
Example().run()
KV = '''
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "Example Tabs"
MDTabs:
id: tabs
'''
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
(continues on next page)
44 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
def on_start(self):
for name_tab in list(md_icons.keys())[15:30]:
self.root.ids.tabs.add_widget(
Tab(
text=f"[size=20][font={fonts[-1]['fn_regular']}]{md_icons[name_
˓→tab]}[/size][/font] {name_tab}"
)
)
Example().run()
KV = '''
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "Example Tabs"
MDTabs:
id: tabs
<Tab>:
MDList:
MDBoxLayout:
adaptive_height: True
MDFlatButton:
text: "ADD TAB"
on_release: app.add_tab()
MDFlatButton:
text: "REMOVE LAST TAB"
on_release: app.remove_tab()
MDFlatButton:
(continues on next page)
2.3. Components 45
KivyMD, Release 0.104.2.dev0
class Example(MDApp):
index = 0
def build(self):
return Builder.load_string(KV)
def on_start(self):
self.add_tab()
def get_tab_list(self):
'''Prints a list of tab objects.'''
print(self.root.ids.tabs.get_tab_list())
def add_tab(self):
self.index += 1
self.root.ids.tabs.add_widget(Tab(text=f"{self.index} tab"))
def remove_tab(self):
if self.index > 1:
self.index -= 1
self.root.ids.tabs.remove_widget(
self.root.ids.tabs.get_tab_list()[0]
)
Example().run()
You can use markup for the text of the tabs and use the on_ref_press method accordingly:
KV = '''
BoxLayout:
orientation: "vertical"
46 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
MDTabs:
id: tabs
on_ref_press: app.on_ref_press(*args)
<Tab>:
MDIconButton:
id: icon
icon: app.icons[0]
user_font_size: "48sp"
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Example(MDApp):
icons = list(md_icons.keys())[15:30]
def build(self):
return Builder.load_string(KV)
def on_start(self):
for name_tab in self.icons:
self.root.ids.tabs.add_widget(
Tab(
text=f"[ref={name_tab}][font={fonts[-1]['fn_regular']}]{md_icons[
˓→'close']}[/font][/ref] {name_tab}"
)
)
def on_ref_press(
self,
instance_tabs,
instance_tab_label,
instance_tab,
instance_tab_bar,
instance_carousel,
):
'''
The method will be called when the ``on_ref_press`` event
occurs when you, for example, use markup text for tabs.
2.3. Components 47
KivyMD, Release 0.104.2.dev0
Example().run()
KV = '''
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "Example Tabs"
MDTabs:
id: tabs
<Tab>:
MDIconButton:
id: icon
icon: "arrow-right"
user_font_size: "48sp"
pos_hint: {"center_x": .5, "center_y": .5}
on_release: app.switch_tab()
'''
class Example(MDApp):
icons = list(md_icons.keys())[15:30]
def build(self):
self.iter_list = iter(list(self.icons))
return Builder.load_string(KV)
def on_start(self):
for name_tab in list(self.icons):
self.root.ids.tabs.add_widget(Tab(text=name_tab))
(continues on next page)
48 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
def switch_tab(self):
'''Switching the tab by name.'''
try:
self.root.ids.tabs.switch_tab(next(self.iter_list))
except StopIteration:
pass
Example().run()
API - kivymd.uix.tab
class kivymd.uix.tab.MDTabsBase(**kwargs)
This class allow you to create a tab. You must create a new class that inherits from MDTabsBase. In this way
you have total control over the views of your tabbed panel.
text
It will be the label text of the tab.
text is an StringProperty and defaults to ‘’.
tab_label
It is the label object reference of the tab.
tab_label is an ObjectProperty and defaults to None.
on_text(self, widget, text)
class kivymd.uix.tab.MDTabs(**kwargs)
You can use this class to create your own tabbed panel..
Events
on_tab_switch Called when switching tabs.
on_slide_progress Called while the slide is scrolling.
on_ref_press The method will be called when the on_ref_press event occurs when you,
for example, use markup text for tabs.
default_tab
Index of the default tab.
default_tab is an NumericProperty and defaults to 0.
tab_bar_height
Height of the tab bar.
tab_bar_height is an NumericProperty and defaults to ‘48dp’.
tab_indicator_anim
Tab indicator animation. If you want use animation set it to True.
tab_indicator_anim is an BooleanProperty and defaults to False.
tab_indicator_height
Height of the tab indicator.
2.3. Components 49
KivyMD, Release 0.104.2.dev0
50 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
remove_widget(self, widget)
Remove a widget from the children of this widget.
Parameters
widget: Widget Widget to remove from our children list.
on_slide_progress(self, *args)
Called while the slide is scrolling.
on_carousel_index(self, carousel, index)
Called when the carousel index changes.
on_ref_press(self, *args)
The method will be called when the on_ref_press event occurs when you, for example, use markup
text for tabs.
on_tab_switch(self, *args)
Called when switching tabs.
2.3. Components 51
KivyMD, Release 0.104.2.dev0
Usage
KV = '''
Screen
MDDropDownItem:
id: drop_item
pos_hint: {'center_x': .5, 'center_y': .5}
text: 'Item'
on_release: self.set_item("New Item")
'''
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
def build(self):
return self.screen
Test().run()
See also:
Work with the class MDDropdownMenu see here
52 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
API - kivymd.uix.dropdownitem
class kivymd.uix.dropdownitem.MDDropDownItem(**kwargs)
Class implements a rectangular ripple effect.
text
Text item.
text is a StringProperty and defaults to ‘’.
current_item
Current name item.
current_item is a StringProperty and defaults to ‘’.
font_size
Item font size.
font_size is a NumericProperty and defaults to ’16sp’.
on_text(self, instance, value)
set_item(self, name_item)
Sets new text for an item.
2.3.7 Pickers
MDTimePicker
Usage
KV = '''
FloatLayout:
MDRaisedButton:
text: "Open time picker"
pos_hint: {'center_x': .5, 'center_y': .5}
on_release: app.show_time_picker()
'''
class Test(MDApp):
def build(self):
(continues on next page)
2.3. Components 53
KivyMD, Release 0.104.2.dev0
def show_time_picker(self):
'''Open time picker dialog.'''
time_dialog = MDTimePicker()
time_dialog.open()
Test().run()
def show_time_picker(self):
time_dialog = MDTimePicker()
time_dialog.bind(time=self.get_time)
time_dialog.open()
return time
def show_time_picker(self):
from datetime import datetime
54 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
MDDatePicker
When creating an instance of the MDDatePicker class, you must pass as a parameter a method that will take one
argument - a datetime object.
def show_date_picker(self):
date_dialog = MDDatePicker(callback=self.get_date)
date_dialog.open()
2.3. Components 55
KivyMD, Release 0.104.2.dev0
def show_date_picker(self):
date_dialog = MDDatePicker(
callback=self.get_date,
year=2010,
month=2,
day=12,
)
date_dialog.open()
You can set the time interval from and to the set date. All days of the week that are not included in this range will have
the status disabled.
def show_date_picker(self):
min_date = datetime.strptime("2020:02:15", '%Y:%m:%d').date()
max_date = datetime.strptime("2020:02:20", '%Y:%m:%d').date()
date_dialog = MDDatePicker(
callback=self.get_date,
min_date=min_date,
max_date=max_date,
)
date_dialog.open()
56 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
MDThemePicker
def show_theme_picker(self):
theme_dialog = MDThemePicker()
theme_dialog.open()
2.3. Components 57
KivyMD, Release 0.104.2.dev0
API - kivymd.uix.picker
return time
58 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
close_cancel(self )
close_ok(self )
class kivymd.uix.picker.MDThemePicker(**kwargs)
Float layout class. See module documentation for more information.
See also:
Material Design spec, Sheets: bottom
Bottom sheets are surfaces containing supplementary content that are anchored to the bottom of
the screen.
Two classes are available to you MDListBottomSheet and MDGridBottomSheet for standard bottom sheets
dialogs:
2.3. Components 59
KivyMD, Release 0.104.2.dev0
Usage MDListBottomSheet
KV = '''
Screen:
MDToolbar:
title: "Example BottomSheet"
pos_hint: {"top": 1}
elevation: 10
MDRaisedButton:
text: "Open list bottom sheet"
on_release: app.show_example_list_bottom_sheet()
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
def show_example_list_bottom_sheet(self):
bottom_sheet_menu = MDListBottomSheet()
for i in range(1, 11):
bottom_sheet_menu.add_item(
f"Standart Item {i}",
lambda x, y=i: self.callback_for_menu_items(
f"Standart Item {y}"
),
)
bottom_sheet_menu.open()
Example().run()
The add_item method of the MDListBottomSheet class takes the following arguments:
text - element text;
callback - function that will be called when clicking on an item;
There is also an optional argument icon, which will be used as an icon to the left of the item:
60 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
KV = '''
Screen:
MDToolbar:
title: 'Example BottomSheet'
pos_hint: {"top": 1}
elevation: 10
MDRaisedButton:
text: "Open grid bottom sheet"
on_release: app.show_example_grid_bottom_sheet()
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
def show_example_grid_bottom_sheet(self):
bottom_sheet_menu = MDGridBottomSheet()
data = {
"Facebook": "facebook-box",
"YouTube": "youtube",
"Twitter": "twitter-box",
"Da Cloud": "cloud-upload",
"Camera": "camera",
}
for item in data.items():
bottom_sheet_menu.add_item(
item[0],
lambda x, y=item[0]: self.callback_for_menu_items(y),
icon_src=item[1],
)
bottom_sheet_menu.open()
2.3. Components 61
KivyMD, Release 0.104.2.dev0
Example().run()
KV = '''
<ItemForCustomBottomSheet@OneLineIconListItem>
on_press: app.custom_sheet.dismiss()
icon: ""
IconLeftWidget:
icon: root.icon
<ContentCustomSheet@BoxLayout>:
orientation: "vertical"
size_hint_y: None
height: "400dp"
MDToolbar:
title: 'Custom bottom sheet:'
ScrollView:
MDGridLayout:
cols: 1
adaptive_height: True
ItemForCustomBottomSheet:
icon: "page-previous"
text: "Preview"
ItemForCustomBottomSheet:
icon: "exit-to-app"
text: "Exit"
Screen:
MDToolbar:
(continues on next page)
62 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
MDRaisedButton:
text: "Open custom bottom sheet"
on_release: app.show_example_custom_bottom_sheet()
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Example(MDApp):
custom_sheet = None
def build(self):
return Builder.load_string(KV)
def show_example_custom_bottom_sheet(self):
self.custom_sheet = MDCustomBottomSheet(screen=Factory.ContentCustomSheet())
self.custom_sheet.open()
Example().run()
Note: When you use the MDCustomBottomSheet class, you must specify the height of the user-defined content
exactly, otherwise dp(100) heights will be used for your ContentCustomSheet class:
<ContentCustomSheet@BoxLayout>:
orientation: "vertical"
size_hint_y: None
height: "400dp"
Note: The height of the bottom sheet dialog will never exceed half the height of the screen!
2.3. Components 63
KivyMD, Release 0.104.2.dev0
API - kivymd.uix.bottomsheet
class kivymd.uix.bottomsheet.MDBottomSheet(**kwargs)
ModalView class. See module documentation for more information.
Events
on_pre_open: Fired before the ModalView is opened. When this event is fired ModalView is
not yet added to window.
on_open: Fired when the ModalView is opened.
on_pre_dismiss: Fired before the ModalView is closed.
on_dismiss: Fired when the ModalView is closed. If the callback returns True, the dismiss will
be canceled.
Changed in version 1.11.0: Added events on_pre_open and on_pre_dismiss.
background
Private attribute.
duration_opening
The duration of the bottom sheet dialog opening animation.
duration_opening is an NumericProperty and defaults to 0.15.
radius
The value of the rounding of the corners of the dialog.
radius is an NumericProperty and defaults to 25.
radius_from
Sets which corners to cut from the dialog. Available options are: (“top_left”, “top_right”, “top”, “bot-
tom_right”, “bottom_left”, “bottom”).
64 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
open(self, *largs)
Show the view window from the attach_to widget. If set, it will attach to the nearest window. If the
widget is not attached to any window, the view will attach to the global Window.
When the view is opened, it will be faded in with an animation. If you don’t want the animation, use:
view.open(animation=False)
on_dismiss(self )
resize_content_layout(self, content, layout, interval=0)
class kivymd.uix.bottomsheet.MDCustomBottomSheet(**kwargs)
ModalView class. See module documentation for more information.
Events
on_pre_open: Fired before the ModalView is opened. When this event is fired ModalView is
not yet added to window.
on_open: Fired when the ModalView is opened.
on_pre_dismiss: Fired before the ModalView is closed.
on_dismiss: Fired when the ModalView is closed. If the callback returns True, the dismiss will
be canceled.
Changed in version 1.11.0: Added events on_pre_open and on_pre_dismiss.
screen
Custom content.
screen is an ObjectProperty and defaults to None.
class kivymd.uix.bottomsheet.MDListBottomSheet(**kwargs)
ModalView class. See module documentation for more information.
Events
2.3. Components 65
KivyMD, Release 0.104.2.dev0
on_pre_open: Fired before the ModalView is opened. When this event is fired ModalView is
not yet added to window.
on_open: Fired when the ModalView is opened.
on_pre_dismiss: Fired before the ModalView is closed.
on_dismiss: Fired when the ModalView is closed. If the callback returns True, the dismiss will
be canceled.
Changed in version 1.11.0: Added events on_pre_open and on_pre_dismiss.
sheet_list
sheet_list is an ObjectProperty and defaults to None.
add_item(self, text, callback, icon=None)
Parameters
• text – element text;
• callback – function that will be called when clicking on an item;
• icon_src – which will be used as an icon to the left of the item;
class kivymd.uix.bottomsheet.GridBottomSheetItem(**kwargs)
This mixin class provides Button behavior. Please see the button behaviors module documentation
for more information.
Events
on_press Fired when the button is pressed.
on_release Fired when the button is released (i.e. the touch/click that pressed the button goes
away).
source
Icon path if you use a local image or icon name if you use icon names from a file kivymd/
icon_definitions.py.
source is an StringProperty and defaults to ‘’.
caption
Item text.
caption is an StringProperty and defaults to ‘’.
icon_size
Icon size.
caption is an StringProperty and defaults to ’32sp’.
class kivymd.uix.bottomsheet.MDGridBottomSheet(**kwargs)
ModalView class. See module documentation for more information.
Events
on_pre_open: Fired before the ModalView is opened. When this event is fired ModalView is
not yet added to window.
on_open: Fired when the ModalView is opened.
on_pre_dismiss: Fired before the ModalView is closed.
on_dismiss: Fired when the ModalView is closed. If the callback returns True, the dismiss will
be canceled.
66 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
See also:
`Material Design spec, Progress indicators https://material.io/components/progress-indicators`_
Progress indicators express an unspecified wait time or display the length of a process.
2.3. Components 67
KivyMD, Release 0.104.2.dev0
MDProgressBar
KV = '''
BoxLayout:
padding: "10dp"
MDProgressBar:
value: 50
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
Vertical orientation
MDProgressBar:
orientation: "vertical"
value: 50
68 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
MDProgressBar:
value: 50
color: app.theme_cls.accent_color
2.3. Components 69
KivyMD, Release 0.104.2.dev0
Indeterminate
KV = '''
Screen:
MDProgressBar:
id: progress
pos_hint: {"center_y": .6}
type: "indeterminate"
MDRaisedButton:
text: "START"
pos_hint: {"center_x": .5, "center_y": .45}
on_press: app.state = "stop" if app.state == "start" else "start"
'''
class Test(MDApp):
state = StringProperty("stop")
def build(self):
return Builder.load_string(KV)
Test().run()
Determinate
MDProgressBar:
type: "determinate"
running_duration: 1
catching_duration: 1.5
70 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
API - kivymd.uix.progressbar
class kivymd.uix.progressbar.MDProgressBar(**kwargs)
Class for creating a progress bar widget.
See module documentation for more details.
reversed
Reverse the direction the progressbar moves.
reversed is an BooleanProperty and defaults to False.
orientation
Orientation of progressbar. Available options are: ‘horizontal ‘, ‘vertical’.
orientation is an OptionProperty and defaults to ‘horizontal’.
color
Progress bar color in rgba format.
color is an OptionProperty and defaults to [].
running_transition
Running transition.
running_transition is an StringProperty and defaults to ‘in_cubic’.
catching_transition
Catching transition.
catching_transition is an StringProperty and defaults to ‘out_quart’.
running_duration
Running duration.
running_duration is an NumericProperty and defaults to 0.5.
catching_duration
Catching duration.
running_duration is an NumericProperty and defaults to 0.8.
type
Type of progressbar. Available options are: ‘indeterminate ‘, ‘determinate’.
type is an OptionProperty and defaults to None.
start(self )
Start animation.
stop(self )
Stop animation.
running_away(self, *args)
catching_up(self, *args)
2.3. Components 71
KivyMD, Release 0.104.2.dev0
2.3.10 Dialog
See also:
Material Design spec, Dialogs
Dialogs inform users about a task and can contain critical information, require decisions, or involve
multiple tasks.
Usage
KV = '''
FloatLayout:
MDFlatButton:
text: "ALERT DIALOG"
pos_hint: {'center_x': .5, 'center_y': .5}
on_release: app.show_alert_dialog()
'''
class Example(MDApp):
dialog = None
def build(self):
return Builder.load_string(KV)
def show_alert_dialog(self):
if not self.dialog:
self.dialog = MDDialog(
text="Discard draft?",
buttons=[
MDFlatButton(
text="CANCEL", text_color=self.theme_cls.primary_color
),
MDFlatButton(
text="DISCARD", text_color=self.theme_cls.primary_color
(continues on next page)
72 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Example().run()
API - kivymd.uix.dialog
class kivymd.uix.dialog.MDDialog(**kwargs)
ModalView class. See module documentation for more information.
Events
on_pre_open: Fired before the ModalView is opened. When this event is fired ModalView is
not yet added to window.
on_open: Fired when the ModalView is opened.
on_pre_dismiss: Fired before the ModalView is closed.
on_dismiss: Fired when the ModalView is closed. If the callback returns True, the dismiss will
be canceled.
Changed in version 1.11.0: Added events on_pre_open and on_pre_dismiss.
title
Title dialog.
self.dialog = MDDialog(
title="Reset settings?",
buttons=[
MDFlatButton(
(continues on next page)
2.3. Components 73
KivyMD, Release 0.104.2.dev0
self.dialog = MDDialog(
title="Reset settings?",
text="This will reset your device to its default factory settings.",
buttons=[
MDFlatButton(
text="CANCEL", text_color=self.theme_cls.primary_color
),
MDFlatButton(
text="ACCEPT", text_color=self.theme_cls.primary_color
),
],
)
74 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
self.dialog = MDDialog(
text="Oops! Something seems to have gone wrong!",
radius=[20, 7, 20, 7],
)
2.3. Components 75
KivyMD, Release 0.104.2.dev0
self.dialog = MDDialog(
text="Discard draft?",
buttons=[
MDFlatButton(text="CANCEL"), MDRaisedButton(text="DISCARD"),
],
)
KV = '''
<Item>
ImageLeftWidget:
source: root.source
FloatLayout:
MDFlatButton:
text: "ALERT DIALOG"
pos_hint: {'center_x': .5, 'center_y': .5}
on_release: app.show_simple_dialog()
'''
(continues on next page)
76 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
class Item(OneLineAvatarListItem):
divider = None
source = StringProperty()
class Example(MDApp):
dialog = None
def build(self):
return Builder.load_string(KV)
def show_simple_dialog(self):
if not self.dialog:
self.dialog = MDDialog(
title="Set backup account",
type="simple",
items=[
Item(text="user01@gmail.com", source="user-1.png"),
Item(text="user02@gmail.com", source="user-2.png"),
Item(text="Add account", source="add-icon.png"),
],
)
self.dialog.open()
Example().run()
2.3. Components 77
KivyMD, Release 0.104.2.dev0
KV = '''
<ItemConfirm>
on_release: root.set_icon(check)
CheckboxLeftWidget:
id: check
group: "check"
FloatLayout:
MDFlatButton:
text: "ALERT DIALOG"
pos_hint: {'center_x': .5, 'center_y': .5}
on_release: app.show_confirmation_dialog()
'''
78 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
class ItemConfirm(OneLineAvatarIconListItem):
divider = None
class Example(MDApp):
dialog = None
def build(self):
return Builder.load_string(KV)
def show_confirmation_dialog(self):
if not self.dialog:
self.dialog = MDDialog(
title="Phone ringtone",
type="confirmation",
items=[
ItemConfirm(text="Callisto"),
ItemConfirm(text="Luna"),
ItemConfirm(text="Night"),
ItemConfirm(text="Solo"),
ItemConfirm(text="Phobos"),
ItemConfirm(text="Diamond"),
ItemConfirm(text="Sirena"),
ItemConfirm(text="Red music"),
ItemConfirm(text="Allergio"),
ItemConfirm(text="Magic"),
ItemConfirm(text="Tic-tac"),
],
buttons=[
MDFlatButton(
text="CANCEL", text_color=self.theme_cls.primary_color
),
MDFlatButton(
text="OK", text_color=self.theme_cls.primary_color
),
],
)
self.dialog.open()
Example().run()
2.3. Components 79
KivyMD, Release 0.104.2.dev0
80 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
KV = '''
<Content>
orientation: "vertical"
spacing: "12dp"
size_hint_y: None
height: "120dp"
MDTextField:
hint_text: "City"
MDTextField:
hint_text: "Street"
FloatLayout:
MDFlatButton:
text: "ALERT DIALOG"
pos_hint: {'center_x': .5, 'center_y': .5}
on_release: app.show_confirmation_dialog()
'''
class Content(BoxLayout):
pass
class Example(MDApp):
dialog = None
def build(self):
return Builder.load_string(KV)
def show_confirmation_dialog(self):
if not self.dialog:
self.dialog = MDDialog(
title="Address:",
type="custom",
content_cls=Content(),
buttons=[
MDFlatButton(
text="CANCEL", text_color=self.theme_cls.primary_color
),
MDFlatButton(
text="OK", text_color=self.theme_cls.primary_color
),
],
)
self.dialog.open()
2.3. Components 81
KivyMD, Release 0.104.2.dev0
Example().run()
82 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Example
<TestAnimationCard@MDBoxLayout>
orientation: 'vertical'
padding: dp(10)
spacing: dp(10)
adaptive_height: True
MDBoxLayout:
adaptive_height: True
Widget:
MDRoundFlatButton:
text: "Free call"
Widget:
MDRoundFlatButton:
text: "Free message"
Widget:
OneLineIconListItem:
text: "Video call"
IconLeftSampleWidget:
icon: 'camera-front-variant'
TwoLineIconListItem:
text: "Call Viber Out"
secondary_text: "[color=%s]Advantageous rates for calls[/color]" % get_hex_
˓→from_color(app.theme_cls.primary_color)
IconLeftSampleWidget:
icon: 'phone'
TwoLineIconListItem:
text: "Call over mobile network"
secondary_text: "[color=%s]Operator's tariffs apply[/color]" % get_hex_from_
˓→color(app.theme_cls.primary_color)
IconLeftSampleWidget:
icon: 'remote'
''')
2.3. Components 83
KivyMD, Release 0.104.2.dev0
class Example(MDApp):
title = "Example Animation Card"
def build(self):
def main_back_callback():
toast('Close card')
if not self.user_animation_card:
self.user_animation_card = MDUserAnimationCard(
user_name="Lion Lion",
path_to_avatar="./assets/african-lion-951778_1280.jpg",
callback=main_back_callback)
self.user_animation_card.box_content.add_widget(
Factory.TestAnimationCard())
self.user_animation_card.open()
Example().run()
API - kivymd.uix.useranimationcard
class kivymd.uix.useranimationcard.MDUserAnimationCard(**kwargs)
ModalView class. See module documentation for more information.
Events
on_pre_open: Fired before the ModalView is opened. When this event is fired ModalView is
not yet added to window.
on_open: Fired when the ModalView is opened.
on_pre_dismiss: Fired before the ModalView is closed.
on_dismiss: Fired when the ModalView is closed. If the callback returns True, the dismiss will
be canceled.
Changed in version 1.11.0: Added events on_pre_open and on_pre_dismiss.
user_name
path_to_avatar
box_content
callback
on_open(self )
on_touch_move(self, touch)
Receive a touch move event. The touch is in parent coordinates.
See on_touch_down() for more information.
84 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
on_touch_down(self, touch)
Receive a touch down event.
Parameters
touch: MotionEvent class Touch received. The touch is in parent coordinates. See
relativelayout for a discussion on coordinate systems.
Returns bool If True, the dispatching of the touch event will stop. If False, the event will
continue to be dispatched to the rest of the widget tree.
on_touch_up(self, touch)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
animation_to_bottom(self )
animation_to_top(self )
class kivymd.uix.useranimationcard.UserAnimationCard(**kwargs)
Float layout class. See module documentation for more information.
user_name
path_to_avatar
class kivymd.uix.useranimationcard.ModifiedToolbar(**kwargs)
Widget class. See module documentation for more information.
Events
on_touch_down: (touch, ) Fired when a new touch event occurs. touch is the touch object.
on_touch_move: (touch, ) Fired when an existing touch moves. touch is the touch object.
on_touch_up: (touch, ) Fired when an existing touch disappears. touch is the touch object.
on_kv_post: (base_widget, ) Fired after all the kv rules associated with the widget and all other
widgets that are in any of those rules have had all their kv rules applied. base_widget is
the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated
from Python, e.g. MyWidget()).
Changed in version 1.11.0.
Warning: Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable
automatic garbage collection for instances of that class. This is because the Widget class creates reference
cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the EventDispatcher.
Event properties can now be used when contructing a simple class without subclassing Widget.
Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to
properties or events, as in the Kv language.
left_action_items
title
on_left_action_items(self, instance, value)
update_action_bar(self, action_bar, action_bar_items)
update_action_bar_text_colors(self, instance, value)
2.3. Components 85
KivyMD, Release 0.104.2.dev0
See also:
Material Design spec, Navigation drawer
When using the class MDNavigationDrawer skeleton of your KV markup should look like this:
Root:
NavigationLayout:
ScreenManager:
Screen_1:
Screen_2:
MDNavigationDrawer:
# This custom rule should implement what will be appear in your
˓→MDNavigationDrawer
ContentNavigationDrawer
86 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
A simple example:
KV = '''
Screen:
NavigationLayout:
ScreenManager:
Screen:
BoxLayout:
orientation: 'vertical'
MDToolbar:
title: "Navigation Drawer"
elevation: 10
left_action_items: [['menu', lambda x: nav_drawer.toggle_nav_
˓→ drawer()]]
Widget:
MDNavigationDrawer:
id: nav_drawer
ContentNavigationDrawer:
'''
class ContentNavigationDrawer(BoxLayout):
pass
class TestNavigationDrawer(MDApp):
def build(self):
return Builder.load_string(KV)
TestNavigationDrawer().run()
Let’s extend the ContentNavigationDrawer class from the above example and create content for our
MDNavigationDrawer panel:
2.3. Components 87
KivyMD, Release 0.104.2.dev0
IconLeftWidget:
id: icon
icon: root.icon
theme_text_color: "Custom"
text_color: root.text_color
class ItemDrawer(OneLineIconListItem):
icon = StringProperty()
<ContentNavigationDrawer>:
orientation: "vertical"
padding: "8dp"
spacing: "8dp"
AnchorLayout:
anchor_x: "left"
size_hint_y: None
height: avatar.height
Image:
id: avatar
size_hint: None, None
size: "56dp", "56dp"
source: "kivymd.png"
MDLabel:
text: "KivyMD library"
font_style: "Button"
size_hint_y: None
height: self.texture_size[1]
MDLabel:
text: "kivydevelopment@gmail.com"
font_style: "Caption"
size_hint_y: None
height: self.texture_size[1]
ScrollView:
DrawerList:
id: md_list
class ContentNavigationDrawer(BoxLayout):
pass
88 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
# Set the color of the icon and text for the menu item.
for item in self.children:
if item.text_color == self.theme_cls.primary_color:
item.text_color = self.theme_cls.text_color
break
instance_item.text_color = self.theme_cls.primary_color
KV = '''
<ContentNavigationDrawer>:
ScrollView:
2.3. Components 89
KivyMD, Release 0.104.2.dev0
OneLineListItem:
text: "Screen 1"
on_press:
root.nav_drawer.set_state("close")
root.screen_manager.current = "scr 1"
OneLineListItem:
text: "Screen 2"
on_press:
root.nav_drawer.set_state("close")
root.screen_manager.current = "scr 2"
Screen:
MDToolbar:
id: toolbar
pos_hint: {"top": 1}
elevation: 10
title: "MDNavigationDrawer"
left_action_items: [["menu", lambda x: nav_drawer.set_state("open")]]
NavigationLayout:
x: toolbar.height
ScreenManager:
id: screen_manager
Screen:
name: "scr 1"
MDLabel:
text: "Screen 1"
halign: "center"
Screen:
name: "scr 2"
MDLabel:
text: "Screen 2"
halign: "center"
MDNavigationDrawer:
id: nav_drawer
ContentNavigationDrawer:
screen_manager: screen_manager
nav_drawer: nav_drawer
'''
class ContentNavigationDrawer(BoxLayout):
screen_manager = ObjectProperty()
nav_drawer = ObjectProperty()
90 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
class TestNavigationDrawer(MDApp):
def build(self):
return Builder.load_string(KV)
TestNavigationDrawer().run()
You can use the standard behavior type for the NavigationDrawer:
MDNavigationDrawer:
type: "standard"
See also:
Full example of Components-Navigation-Drawer
API - kivymd.uix.navigationdrawer
class kivymd.uix.navigationdrawer.NavigationLayout(**kwargs)
Float layout class. See module documentation for more information.
update_pos(self, *args)
add_scrim(self, widget)
update_scrim_rectangle(self, *args)
add_widget(self, widget, index=0, canvas=None)
Only two layouts are allowed: ScreenManager and MDNavigationDrawer.
class kivymd.uix.navigationdrawer.MDNavigationDrawer(**kwargs)
Widget class. See module documentation for more information.
Events
on_touch_down: (touch, ) Fired when a new touch event occurs. touch is the touch object.
on_touch_move: (touch, ) Fired when an existing touch moves. touch is the touch object.
on_touch_up: (touch, ) Fired when an existing touch disappears. touch is the touch object.
on_kv_post: (base_widget, ) Fired after all the kv rules associated with the widget and all other
widgets that are in any of those rules have had all their kv rules applied. base_widget is
the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated
from Python, e.g. MyWidget()).
Changed in version 1.11.0.
Warning: Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable
automatic garbage collection for instances of that class. This is because the Widget class creates reference
cycles, thereby preventing garbage collection.
2.3. Components 91
KivyMD, Release 0.104.2.dev0
Changed in version 1.0.9: Everything related to event properties has been moved to the EventDispatcher.
Event properties can now be used when contructing a simple class without subclassing Widget.
Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to
properties or events, as in the Kv language.
type
Type of drawer. Modal type will be on top of screen. Standard type will be at left or right of screen.
Also it automatically disables close_on_click and enable_swiping to prevent closing drawer
for standard type.
type is a OptionProperty and defaults to modal.
anchor
Anchoring screen edge for drawer. Set it to ‘right’ for right-to-left languages. Available options are: ‘left’,
‘right’.
anchor is a OptionProperty and defaults to left.
close_on_click
Close when click on scrim or keyboard escape. It automatically sets to False for “standard” type.
close_on_click is a BooleanProperty and defaults to True.
state
Indicates if panel closed or opened. Sets after status change. Available options are: ‘close’, ‘open’.
state is a OptionProperty and defaults to ‘close’.
status
Detailed state. Sets before state. Bind to state instead of status. Available options
are: ‘closed’, ‘opening_with_swipe’, ‘opening_with_animation’, ‘opened’, ‘closing_with_swipe’, ‘clos-
ing_with_animation’.
status is a OptionProperty and defaults to ‘closed’.
open_progress
Percent of visible part of side panel. The percent is specified as a floating point number in the range 0-1.
0.0 if panel is closed and 1.0 if panel is opened.
open_progress is a NumericProperty and defaults to 0.0.
enable_swiping
Allow to open or close navigation drawer with swipe. It automatically sets to False for “standard” type.
enable_swiping is a BooleanProperty and defaults to True.
swipe_distance
The distance of the swipe with which the movement of navigation drawer begins.
swipe_distance is a NumericProperty and defaults to 10.
swipe_edge_width
The size of the area in px inside which should start swipe to drag navigation drawer.
swipe_edge_width is a NumericProperty and defaults to 20.
scrim_color
Color for scrim. Alpha channel will be multiplied with _scrim_alpha. Set fourth channel to 0 if you
want to disable scrim.
scrim_color is a ListProperty and defaults to [0, 0, 0, 0.5].
92 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
scrim_alpha_transition
The name of the animation transition type to use for changing scrim_alpha.
scrim_alpha_transition is a StringProperty and defaults to ‘linear’.
opening_transition
The name of the animation transition type to use when animating to the state ‘open’.
opening_transition is a StringProperty and defaults to ‘out_cubic’.
opening_time
The time taken for the panel to slide to the state ‘open’.
opening_time is a NumericProperty and defaults to 0.2.
closing_transition
The name of the animation transition type to use when animating to the state ‘close’.
closing_transition is a StringProperty and defaults to ‘out_sine’.
closing_time
The time taken for the panel to slide to the state ‘close’.
closing_time is a NumericProperty and defaults to 0.2.
on_type(self, *args)
set_state(self, new_state='toggle', animation=True)
Change state of the side panel. New_state can be one of “toggle”, “open” or “close”.
toggle_nav_drawer(self )
update_status(self, *_)
get_dist_from_side(self, x)
on_touch_down(self, touch)
Receive a touch down event.
Parameters
touch: MotionEvent class Touch received. The touch is in parent coordinates. See
relativelayout for a discussion on coordinate systems.
Returns bool If True, the dispatching of the touch event will stop. If False, the event will
continue to be dispatched to the rest of the widget tree.
on_touch_move(self, touch)
Receive a touch move event. The touch is in parent coordinates.
See on_touch_down() for more information.
on_touch_up(self, touch)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
2.3. Components 93
KivyMD, Release 0.104.2.dev0
See also:
Material Design spec, Expansion panel
Expansion panels contain creation flows and allow lightweight editing of an element.
Usage
self.add_widget(
MDExpansionPanel(
icon="logo.png", # panel icon
content=Content(), # panel content
panel_cls=MDExpansionPanelOneLine(text="Secondary text"), # panel class
)
)
To use MDExpansionPanel you must pass one of the following classes to the panel_cls parameter:
• MDExpansionPanelOneLine
• MDExpansionPanelTwoLine
• MDExpansionPanelThreeLine
These classes are inherited from the following classes:
• OneLineAvatarIconListItem
• TwoLineAvatarIconListItem
• ThreeLineAvatarIconListItem
self.root.ids.box.add_widget(
MDExpansionPanel(
icon="logo.png",
content=Content(),
panel_cls=MDExpansionPanelThreeLine(
text="Text",
secondary_text="Secondary text",
tertiary_text="Tertiary text",
)
)
)
94 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Example
KV = '''
<Content>
adaptive_height: True
TwoLineIconListItem:
text: "(050)-123-45-67"
secondary_text: "Mobile"
IconLeftWidget:
icon: 'phone'
ScrollView:
MDGridLayout:
id: box
cols: 1
adaptive_height: True
'''
class Content(MDBoxLayout):
'''Custom content.'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
def on_start(self):
for i in range(10):
self.root.ids.box.add_widget(
MDExpansionPanel(
icon=f"{images_path}kivymd.png",
content=Content(),
panel_cls=MDExpansionPanelThreeLine(
text="Text",
secondary_text="Secondary text",
tertiary_text="Tertiary text",
)
)
)
Test().run()
2.3. Components 95
KivyMD, Release 0.104.2.dev0
• on_open
• on_close
MDExpansionPanel:
on_open: app.on_panel_open(args)
on_close: app.on_panel_close(args)
The user function takes one argument - the object of the panel:
See also:
See Expansion panel example
Expansion panel and MDCard
API - kivymd.uix.expansionpanel
class kivymd.uix.expansionpanel.MDExpansionPanelOneLine(**kwargs)
Single line panel.
class kivymd.uix.expansionpanel.MDExpansionPanelTwoLine(**kwargs)
Two-line panel.
class kivymd.uix.expansionpanel.MDExpansionPanelThreeLine(**kwargs)
Three-line panel.
class kivymd.uix.expansionpanel.MDExpansionPanel(**kwargs)
Events
content
Content of panel. Must be Kivy widget.
content is an ObjectProperty and defaults to None.
icon
Icon of panel.
Icon Should be either be a path to an image or a logo name in md_icons
icon is an StringProperty and defaults to ‘’.
opening_transition
The name of the animation transition type to use when animating to the state ‘open’.
opening_transition is a StringProperty and defaults to ‘out_cubic’.
opening_time
The time taken for the panel to slide to the state ‘open’.
opening_time is a NumericProperty and defaults to 0.2.
96 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
closing_transition
The name of the animation transition type to use when animating to the state ‘close’.
closing_transition is a StringProperty and defaults to ‘out_sine’.
closing_time
The time taken for the panel to slide to the state ‘close’.
closing_time is a NumericProperty and defaults to 0.2.
panel_cls
Panel object. The object must be one of the classes MDExpansionPanelOneLine,
MDExpansionPanelTwoLine or MDExpansionPanelThreeLine.
panel_cls is a ObjectProperty and defaults to None.
on_open(self, *args)
Called when a panel is opened.
on_close(self, *args)
Called when a panel is closed.
check_open_panel(self, instance)
Called when you click on the panel. Called methods to open or close a panel.
set_chevron_down(self )
Sets the chevron down.
set_chevron_up(self, instance_chevron)
Sets the chevron up.
close_panel(self, instance_panel)
Method closes the panel.
open_panel(self, *args)
Method opens a panel.
add_widget(self, widget, index=0, canvas=None)
Add a new widget as a child of this widget.
Parameters
widget: Widget Widget to add to our list of children.
index: int, defaults to 0 Index to insert the widget in the list. Notice that the default
of 0 means the widget is inserted at the beginning of the list and will thus be drawn
on top of other sibling widgets. For a full discussion of the index and widget hier-
archy, please see the Widgets Programming Guide.
New in version 1.0.5.
canvas: str, defaults to None Canvas to add widget’s canvas to. Can be ‘before’,
‘after’ or None for the default canvas.
New in version 1.9.0.
2.3. Components 97
KivyMD, Release 0.104.2.dev0
2.3.14 Toolbar
See also:
Material Design spec, App bars: top
Material Design spec, App bars: bottom
Top
KV = '''
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "MDToolbar"
MDLabel:
text: "Content"
halign: "center"
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
98 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
MDToolbar:
title: "MDToolbar"
left_action_items: [["menu", lambda x: app.callback()]]
MDToolbar:
title: "MDToolbar"
right_action_items: [["dots-vertical", lambda x: app.callback()]]
2.3. Components 99
KivyMD, Release 0.104.2.dev0
MDToolbar:
title: "MDToolbar"
right_action_items: [["dots-vertical", lambda x: app.callback_1()], ["clock",
˓→lambda x: app.callback_2()]]
MDToolbar:
title: "MDToolbar"
md_bg_color: app.theme_cls.accent_color
MDToolbar:
title: "MDToolbar"
specific_text_color: app.theme_cls.accent_color
MDToolbar:
title: "Elevation 10"
elevation: 10
Bottom
Usage
KV = '''
BoxLayout:
MDToolbar:
title: "Title"
icon: "git"
type: "bottom"
left_action_items: [["menu", lambda x: x]]
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
Event on_action_button:
MDBottomAppBar:
MDToolbar:
title: "Title"
icon: "git"
type: "bottom"
left_action_items: [["menu", lambda x: x]]
on_action_button: app.callback(self.icon)
Mode:
• ’free-end’
• ’free-center’
• ’end’
• ’center’
MDBottomAppBar:
MDToolbar:
title: "Title"
icon: "git"
type: "bottom"
left_action_items: [["menu", lambda x: x]]
mode: "end"
MDBottomAppBar:
MDToolbar:
title: "Title"
icon: "git"
type: "bottom"
left_action_items: [["menu", lambda x: x]]
mode: "free-end"
See also:
Components-Bottom-App-Bar
API - kivymd.uix.toolbar
class kivymd.uix.toolbar.MDActionBottomAppBarButton(**kwargs)
Abstract base class for all round buttons, bringing in the appropriate on-touch behavior
class kivymd.uix.toolbar.MDToolbar(**kwargs)
Events
on_action_button Method for the button used for the MDBottomAppBar class.
elevation
Elevation value.
elevation is an NumericProperty and defaults to 6.
left_action_items
The icons on the left of the toolbar. To add one, append a list like the following:
where ‘icon_name’ is a string that corresponds to an icon definition and callback is the function called
on a touch release event.
left_action_items is an ListProperty and defaults to [].
right_action_items
The icons on the left of the toolbar. Works the same way as left_action_items.
right_action_items is an ListProperty and defaults to [].
title
Text toolbar.
title is an StringProperty and defaults to ‘’.
md_bg_color
Color toolbar.
md_bg_color is an ListProperty and defaults to [0, 0, 0, 0].
anchor_title
mode
Floating button position. Onle for MDBottomAppBar class. Available options are: ‘free-end’, ‘free-
center’, ‘end’, ‘center’.
mode is an OptionProperty and defaults to ‘center’.
round
Rounding the corners at the notch for a button. Onle for MDBottomAppBar class.
round is an NumericProperty and defaults to ‘10dp’.
icon
Floating button. Onle for MDBottomAppBar class.
icon is an StringProperty and defaults to ‘android’.
icon_color
Color action button. Onle for MDBottomAppBar class.
icon_color is an ListProperty and defaults to [].
type
When using the MDBottomAppBar class, the parameter type must be set to ‘bottom’:
MDBottomAppBar:
MDToolbar:
type: "bottom"
2.3.15 Menu
See also:
Material Design spec, Menus
Usage
KV = '''
Screen:
MDRaisedButton:
id: button
text: "PRESS ME"
pos_hint: {"center_x": .5, "center_y": .5}
on_release: app.menu.open()
(continues on next page)
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
menu_items = [{"text": f"Item {i}"} for i in range(5)]
self.menu = MDDropdownMenu(
caller=self.screen.ids.button,
items=menu_items,
width_mult=4,
)
self.menu.bind(on_release=self.menu_callback)
def build(self):
return self.screen
Test().run()
Warning: Do not create the MDDropdownMenu object when you open the menu window. Because on a mobile
device this one will be very slow!
Wrong
You must create a new class that inherits from the RightContent class:
class RightContentCls(RightContent):
pass
Now in the KV rule you can create your own elements that will be displayed in the menu item on the right:
<RightContentCls>
disabled: True
MDIconButton:
icon: root.icon
(continues on next page)
MDLabel:
text: root.text
font_style: "Caption"
size_hint_x: None
width: self.texture_size[0]
text_size: None, None
Now create menu items as usual, but add the key right_content_cls whose value is the class
RightContentCls that you created:
menu_items = [
{
"right_content_cls": RightContentCls(
text=f"R+{i}", icon="apple-keyboard-command",
),
"icon": "git",
"text": f"Item {i}",
}
for i in range(5)
]
self.menu = MDDropdownMenu(
caller=self.screen.ids.button, items=menu_items, width_mult=4
)
Full example
KV = '''
<RightContentCls>
disabled: True
MDIconButton:
icon: root.icon
user_font_size: "16sp"
pos_hint: {"center_y": .5}
MDLabel:
text: root.text
font_style: "Caption"
size_hint_x: None
width: self.texture_size[0]
text_size: None, None
(continues on next page)
Screen:
MDRaisedButton:
id: button
text: "PRESS ME"
pos_hint: {"center_x": .5, "center_y": .5}
on_release: app.menu.open()
'''
class RightContentCls(RightContent):
pass
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
menu_items = [
{
"right_content_cls": RightContentCls(
text=f"R+{i}", icon="apple-keyboard-command",
),
"icon": "git",
"text": f"Item {i}",
}
for i in range(5)
]
self.menu = MDDropdownMenu(
caller=self.screen.ids.button, items=menu_items, width_mult=4
)
self.menu.bind(on_release=self.menu_callback)
def build(self):
return self.screen
Test().run()
If you do not want to use the icons in the menu items on the left, then do not use the “icon” key when creating menu
items:
menu_items = [
{
"right_content_cls": RightContentCls(
text=f"R+{i}", icon="apple-keyboard-command",
),
"text": f"Item {i}",
(continues on next page)
menu_items = [
{
"right_content_cls": RightContentCls(
text=f"R+{i}", icon="apple-keyboard-command",
),
"text": f"Item {i}",
"height": "36dp",
"top_pad": "10dp",
"bot_pad": "10dp",
}
for i in range(5)
]
Mixin items
KV = '''
<RightContentCls>
disabled: True
MDIconButton:
icon: root.icon
user_font_size: "16sp"
pos_hint: {"center_y": .5}
MDLabel:
text: root.text
font_style: "Caption"
size_hint_x: None
width: self.texture_size[0]
text_size: None, None
Screen:
MDRaisedButton:
id: button
text: "PRESS ME"
pos_hint: {"center_x": .5, "center_y": .5}
on_release: app.menu.open()
'''
class RightContentCls(RightContent):
pass
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
menu_items = []
data = [
{"": "Open"},
{},
{"open-in-app": "Open in app >"},
{"trash-can-outline": "Move to Trash"},
(continues on next page)
def build(self):
return self.screen
Test().run()
Hover Behavior
self.menu = MDDropdownMenu(
...,
...,
selected_color=self.theme_cls.primary_dark_hue,
)
Create submenu
KV = '''
Screen:
MDRaisedButton:
id: button
text: "PRESS ME"
pos_hint: {"center_x": .5, "center_y": .5}
on_release: app.menu.open()
'''
class Test(MDApp):
submenu = None
def build(self):
return self.screen
Test().run()
Warning: The MDDropdownMenu does not work with the standard MDToolbar. You can use your own
CustomToolbar and bind the menu window output to its elements.
KV = '''
<CustomToolbar>:
size_hint_y: None
height: self.theme_cls.standard_increment
padding: "5dp"
spacing: "12dp"
MDIconButton:
id: button_1
icon: "menu"
pos_hint: {"center_y": .5}
on_release: app.menu_1.open()
MDLabel:
text: "MDDropdownMenu"
pos_hint: {"center_y": .5}
size_hint_x: None
width: self.texture_size[0]
text_size: None, None
font_style: 'H6'
Widget:
MDIconButton:
id: button_2
icon: "dots-vertical"
pos_hint: {"center_y": .5}
on_release: app.menu_2.open()
Screen:
CustomToolbar:
id: toolbar
elevation: 10
pos_hint: {"top": 1}
'''
class CustomToolbar(
ThemableBehavior, RectangularElevationBehavior, MDBoxLayout,
):
(continues on next page)
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
self.menu_1 = self.create_menu(
"Button menu", self.screen.ids.toolbar.ids.button_1,
)
self.menu_2 = self.create_menu(
"Button dots", self.screen.ids.toolbar.ids.button_2,
)
def build(self):
return self.screen
Test().run()
Position menu
Bottom position
See also:
position
KV = '''
Screen
MDTextField:
id: field
pos_hint: {'center_x': .5, 'center_y': .5}
size_hint_x: None
width: "200dp"
(continues on next page)
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
menu_items = [{"icon": "git", "text": f"Item {i}"} for i in range(5)]
self.menu = MDDropdownMenu(
caller=self.screen.ids.field,
items=menu_items,
position="bottom",
width_mult=4,
)
self.menu.bind(on_release=self.set_item)
def build(self):
return self.screen
Test().run()
Center position
KV = '''
Screen
MDDropDownItem:
id: drop_item
pos_hint: {'center_x': .5, 'center_y': .5}
text: 'Item 0'
on_release: app.menu.open()
'''
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
menu_items = [{"icon": "git", "text": f"Item {i}"} for i in range(5)]
(continues on next page)
def build(self):
return self.screen
Test().run()
API - kivymd.uix.menu
class kivymd.uix.menu.RightContent(**kwargs)
Same as IRightBody, but allows the widget to receive touch events instead of triggering the ListItem’s
ripple effect
text
Text item.
text is a StringProperty and defaults to ‘’.
icon
Icon item.
icon is a StringProperty and defaults to ‘’.
class kivymd.uix.menu.MDDropdownMenu(**kwargs)
Events
selected_color
Custom color (rgba format) for list item when hover behavior occurs.
selected_color is a ListProperty and defaults to [].
items
See data.
items is a ListProperty and defaults to [].
width_mult
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.
width_mult is a NumericProperty and defaults to 1.
max_height
The menu will grow no bigger than this number. Set to 0 for no limit.
max_height is a NumericProperty and defaults to 0.
border_margin
Margin between Window border and menu.
border_margin is a NumericProperty and defaults to 4dp.
ver_growth
Where the menu will grow vertically to when opening. Set to None to let the widget pick for you. Available
options are: ‘up’, ‘down’.
ver_growth is a OptionProperty and defaults to None.
hor_growth
Where the menu will grow horizontally to when opening. Set to None to let the widget pick for you.
Available options are: ‘left’, ‘right’.
hor_growth is a OptionProperty and defaults to None.
background_color
Color of the background of the menu.
background_color is a ListProperty and defaults to [].
opening_transition
Type of animation for opening a menu window.
opening_transition is a StringProperty and defaults to ‘out_cubic’.
opening_time
Menu window opening animation time.
opening_time is a NumericProperty and defaults to 0.2.
caller
The widget object that caller the menu window.
caller is a ObjectProperty and defaults to None.
position
Menu window position relative to parent element. Available options are: ‘auto’, ‘center’, ‘bottom’.
position is a OptionProperty and defaults to ‘auto’.
check_position_caller(self, instance, width, height)
set_bg_color_items(self, instance_selected_item)
Called when a Hover Behavior event occurs for a list item.
create_menu_items(self )
Creates menu items.
set_menu_properties(self, interval=0)
Sets the size and position for the menu window.
open(self )
Animate the opening of a menu window.
on_touch_down(self, touch)
Receive a touch down event.
Parameters
touch: MotionEvent class Touch received. The touch is in parent coordinates. See
relativelayout for a discussion on coordinate systems.
Returns bool If True, the dispatching of the touch event will stop. If False, the event will
continue to be dispatched to the rest of the widget tree.
on_touch_move(self, touch)
Receive a touch move event. The touch is in parent coordinates.
See on_touch_down() for more information.
on_touch_up(self, touch)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
on_enter(self, instance)
Call when mouse enter the bbox of the item of menu.
on_leave(self, instance)
Call when the mouse exit the item of menu.
on_release(self, *args)
The method that will be called when you click menu items.
on_dismiss(self )
Called when the menu is closed.
dismiss(self )
Closes the menu.
2.3.16 FloatLayout
FloatLayout class equivalent. Simplifies working with some widget properties. For example:
FloatLayout
FloatLayout:
canvas:
Color:
rgba: app.theme_cls.primary_color
RoundedRectangle:
pos: self.pos
size: self.size
radius: [25, 0, 0, 0]
MDFloatLayout
MDFloatLayout:
radius: [25, 0, 0, 0]
md_bg_color: app.theme_cls.primary_color
Warning: For a FloatLayout, the minimum_size attributes are always 0, so you cannot use
adaptive_size and related options.
API - kivymd.uix.floatlayout
class kivymd.uix.floatlayout.MDFloatLayout(**kwargs)
Float layout class. See module documentation for more information.
2.3.17 GridLayout
GridLayout class equivalent. Simplifies working with some widget properties. For example:
GridLayout
GridLayout:
size_hint_y: None
height: self.minimum_height
canvas:
Color:
rgba: app.theme_cls.primary_color
Rectangle:
pos: self.pos
size: self.size
MDGridLayout
MDGridLayout:
adaptive_height: True
md_bg_color: app.theme_cls.primary_color
• adaptive_height
• adaptive_width
• adaptive_size
adaptive_height
adaptive_height: True
Equivalent
size_hint_y: None
height: self.minimum_height
adaptive_width
adaptive_width: True
Equivalent
size_hint_x: None
height: self.minimum_width
adaptive_size
adaptive_size: True
Equivalent
API - kivymd.uix.gridlayout
class kivymd.uix.gridlayout.MDGridLayout(**kwargs)
Grid layout class. See module documentation for more information.
2.3.18 Button
See also:
Material Design spec, Buttons
Material Design spec, Buttons: floating action button
Buttons allow users to take actions, and make choices, with a single tap.
MDIconButton
MDIconButton
KV = '''
Screen:
MDIconButton:
icon: "language-python"
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
Example().run()
The icon parameter must have the name of the icon from kivymd/icon_definitions.py file.
You can also use custom icons:
MDIconButton:
icon: "data/logo/kivy-icon-256.png"
By default, MDIconButton button has a size (dp(48), dp (48)). Use user_font_size attribute to resize
the button:
MDIconButton:
icon: "android"
user_font_size: "64sp"
By default, the color of MDIconButton (depending on the style of the application) is black or white. You can change
the color of MDIconButton as the text color of MDLabel:
MDIconButton:
icon: "android"
theme_text_color: "Custom"
text_color: app.theme_cls.primary_color
MDFloatingActionButton
MDFloatingActionButton:
icon: "android"
md_bg_color: app.theme_cls.primary_color
MDFloatingActionButton:
icon: "android"
elevation_normal: 12
MDFlatButton
To change the text color of: class:~MDFlatButton use the text_color parameter:
MDFlatButton:
text: "MDFLATBUTTON"
text_color: 0, 0, 1, 1
Or use markup:
MDFlatButton:
text: "[color=#00ffcc]MDFLATBUTTON[/color]"
markup: True
To specify the font size and font name, use the parameters as in the usual Kivy buttons:
MDFlatButton:
text: "MDFLATBUTTON"
font_size: "18sp"
font_name: "path/to/font"
Warning: You cannot use the size_hint_x parameter for KivyMD buttons (the width of the buttons is set
automatically)!
MDRaisedButton
This button is similar to the MDFlatButton button except that you can set the background color for
MDRaisedButton:
MDRaisedButton:
text: "MDRAISEDBUTTON"
md_bg_color: 1, 0, 1, 1
MDRectangleFlatButton
MDRectangleFlatButton:
text: "MDRECTANGLEFLATBUTTON"
text_color: 0, 0, 1, 1
md_bg_color: 1, 1, 0, 1
Note: Note that the frame color will be the same as the text color.
MDRectangleFlatIconButton
MDRectangleFlatIconButton:
icon: "android"
text: "MDRECTANGLEFLATICONBUTTON"
Without border
class Example(MDApp):
def build(self):
screen = Screen()
screen.add_widget(
MDRectangleFlatIconButton(
text="MDRectangleFlatIconButton",
icon="language-python",
line_color=(0, 0, 0, 0),
pos_hint={"center_x": .5, "center_y": .5},
)
)
return screen
Example().run()
MDRectangleFlatIconButton:
text: "MDRectangleFlatIconButton"
icon: "language-python"
line_color: 0, 0, 0, 0
pos_hint: {"center_x": .5, "center_y": .5}
MDRoundFlatButton
MDRoundFlatButton:
text: "MDROUNDFLATBUTTON"
Warning: The border color does change when using text_color parameter.
MDRoundFlatButton:
text: "MDROUNDFLATBUTTON"
text_color: 0, 1, 0, 1
MDRoundFlatIconButton
MDRoundFlatIconButton:
icon: "android"
text: "MDROUNDFLATICONBUTTON"
MDFillRoundFlatButton
MDFillRoundFlatIconButton
Note: Notice that the width of the MDFillRoundFlatIconButton button matches the size of the button text.
MDTextButton
MDTextButton:
text: "MDTEXTBUTTON"
custom_color: 0, 1, 0, 1
MDFloatingActionButtonSpeedDial
KV = '''
Screen:
MDFloatingActionButtonSpeedDial:
data: app.data
rotation_root_button: True
'''
class Example(MDApp):
data = {
'language-python': 'Python',
'language-php': 'PHP',
'language-cpp': 'C++',
}
def build(self):
return Builder.load_string(KV)
Example().run()
Or without KV Language:
from kivy.uix.screenmanager import Screen
class Example(MDApp):
data = {
'language-python': 'Python',
'language-php': 'PHP',
'language-cpp': 'C++',
}
def build(self):
screen = Screen()
speed_dial = MDFloatingActionButtonSpeedDial()
speed_dial.data = self.data
speed_dial.rotation_root_button = True
screen.add_widget(speed_dial)
return screen
You can use various types of animation of labels for buttons on the stack:
MDFloatingActionButtonSpeedDial:
hint_animation: True
You can set your color values for background, text of buttons etc:
MDFloatingActionButtonSpeedDial:
bg_hint_color: app.theme_cls.primary_light
See also:
See full example
API - kivymd.uix.button
class kivymd.uix.button.MDIconButton(**kwargs)
Abstract base class for all round buttons, bringing in the appropriate on-touch behavior
icon
Button icon.
icon is an StringProperty and defaults to ‘checkbox-blank-circle’.
class kivymd.uix.button.MDFlatButton(**kwargs)
Abstract base class for all rectangular buttons, bringing in the appropriate on-touch behavior. Also maintains
the correct minimum width as stated in guidelines.
class kivymd.uix.button.MDRaisedButton(**kwargs)
Abstract base class for all rectangular buttons, bringing in the appropriate on-touch behavior. Also maintains
the correct minimum width as stated in guidelines.
class kivymd.uix.button.MDFloatingActionButton(**kwargs)
Abstract base class for all round buttons, bringing in the appropriate on-touch behavior
icon
Button icon.
icon is an StringProperty and defaults to ‘android’.
background_palette
The name of the palette used for the background color of the button.
background_palette is an StringProperty and defaults to ‘Accent’.
on_md_bg_color(self, instance, value)
class kivymd.uix.button.MDRectangleFlatButton(**kwargs)
Abstract base class for all rectangular buttons, bringing in the appropriate on-touch behavior. Also maintains
the correct minimum width as stated in guidelines.
update_md_bg_color(self, instance, value)
Called when the application color palette changes.
on_disabled(self, instance, value)
class kivymd.uix.button.MDRoundFlatButton(**kwargs)
Abstract base class for all rectangular buttons, bringing in the appropriate on-touch behavior. Also maintains
the correct minimum width as stated in guidelines.
update_md_bg_color(self, instance, value)
Called when the application color palette changes.
lay_canvas_instructions(self )
class kivymd.uix.button.MDTextButton(**kwargs)
Button class, see module documentation for more information.
Changed in version 1.8.0: The behavior / logic of the button has been moved to ButtonBehaviors.
custom_color
Custom user button color in rgba format.
custom_color is an ListProperty and defaults to [].
animation_label(self )
on_press(self, *args)
icon
Root button icon name.
icon is a StringProperty and defaults to ‘plus’.
anchor
Stack anchor. Available options are: ‘right’.
anchor is a OptionProperty and defaults to ‘right’.
callback
Custom callback.
MDFloatingActionButtonSpeedDial:
callback: app.callback
{
'name-icon': 'Text label',
...,
...,
}
right_pad
If True, the button will increase on the right side by 2.5 piesels if the hint_animation parameter equal
to True.
False
True
closing_transition
The name of the stack closing animation type.
closing_transition is a StringProperty and defaults to ‘out_cubic’.
opening_transition_button_rotation
The name of the animation type to rotate the root button when opening the stack.
opening_transition_button_rotation is a StringProperty and defaults to ‘out_cubic’.
closing_transition_button_rotation
The name of the animation type to rotate the root button when closing the stack.
closing_transition_button_rotation is a StringProperty and defaults to ‘out_cubic’.
opening_time
Time required for the stack to go to: attr:state ‘open’.
opening_time is a NumericProperty and defaults to 0.2.
closing_time
Time required for the stack to go to: attr:state ‘close’.
closing_time is a NumericProperty and defaults to 0.2.
opening_time_button_rotation
Time required to rotate the root button 45 degrees during the stack opening animation.
opening_time_button_rotation is a NumericProperty and defaults to 0.2.
closing_time_button_rotation
Time required to rotate the root button 0 degrees during the stack closing animation.
closing_time_button_rotation is a NumericProperty and defaults to 0.2.
state
Indicates whether the stack is closed or open. Available options are: ‘close’, ‘open’.
state is a OptionProperty and defaults to ‘close’.
bg_color_root_button
Root button color in rgba format.
bg_color_root_button is a ListProperty and defaults to [].
bg_color_stack_button
The color of the buttons in the stack rgba format.
bg_color_stack_button is a ListProperty and defaults to [].
color_icon_stack_button
The color icon of the buttons in the stack rgba format.
color_icon_stack_button is a ListProperty and defaults to [].
color_icon_root_button
The color icon of the root button rgba format.
color_icon_root_button is a ListProperty and defaults to [].
bg_hint_color
Background color for the text of the buttons in the stack rgba format.
bg_hint_color is a ListProperty and defaults to [].
hint_animation
Whether to use button extension animation to display text labels.
hint_animation is a BooleanProperty and defaults to False.
on_open(self, *args)
Called when a stack is opened.
on_close(self, *args)
Called when a stack is closed.
on_leave(self, instance)
Called when the mouse cursor goes outside the button of stack.
on_enter(self, instance)
Called when the mouse cursor is over a button from the stack.
on_data(self, instance, value)
Creates a stack of buttons.
on_icon(self, instance, value)
on_label_text_color(self, instance, value)
on_color_icon_stack_button(self, instance, value)
on_hint_animation(self, instance, value)
on_bg_hint_color(self, instance, value)
on_color_icon_root_button(self, instance, value)
on_bg_color_stack_button(self, instance, value)
on_bg_color_root_button(self, instance, value)
set_pos_labels(self, widget)
Sets the position of the floating labels.
set_pos_root_button(self, instance)
Sets the position of the root button.
set_pos_bottom_buttons(self, instance)
Sets the position of the bottom buttons in a stack.
open_stack(self, instance)
Opens a button stack.
do_animation_open_stack(self, anim_data)
close_stack(self )
Closes the button stack.
2.3.19 BoxLayout
BoxLayout class equivalent. Simplifies working with some widget properties. For example:
BoxLayout
BoxLayout:
size_hint_y: None
height: self.minimum_height
canvas:
Color:
rgba: app.theme_cls.primary_color
Rectangle:
pos: self.pos
size: self.size
MDBoxLayout
MDBoxLayout:
adaptive_height: True
md_bg_color: app.theme_cls.primary_color
• adaptive_height
• adaptive_width
• adaptive_size
adaptive_height
adaptive_height: True
Equivalent
size_hint_y: None
height: self.minimum_height
adaptive_width
adaptive_width: True
Equivalent
size_hint_x: None
height: self.minimum_width
adaptive_size
adaptive_size: True
Equivalent
API - kivymd.uix.boxlayout
class kivymd.uix.boxlayout.MDBoxLayout(**kwargs)
Box layout class. See module documentation for more information.
See also:
Material Design spec, Selection controls
MDCheckbox
KV = '''
FloatLayout:
MDCheckbox:
size_hint: None, None
size: "48dp", "48dp"
pos_hint: {'center_x': .5, 'center_y': .5}
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
Note: Be sure to specify the size of the checkbox. By default, it is (dp(48), dp(48)), but the ripple effect takes
up all the available space.
Control state
MDCheckbox:
on_active: app.on_checkbox_active(*args)
KV = '''
<Check@MDCheckbox>:
group: 'group'
(continues on next page)
FloatLayout:
Check:
active: True
pos_hint: {'center_x': .4, 'center_y': .5}
Check:
pos_hint: {'center_x': .6, 'center_y': .5}
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
MDSwitch
KV = '''
FloatLayout:
MDSwitch:
pos_hint: {'center_x': .5, 'center_y': .5}
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
Note: For MDCheckbox size is not required. By default it is (dp(36), dp(48)), but you can increase the width
if you want.
MDSwitch:
width: dp(64)
API - kivymd.uix.selectioncontrol
class kivymd.uix.selectioncontrol.MDCheckbox(**kwargs)
Class implements a circular ripple effect.
active
Indicates if the checkbox is active or inactive.
active is a BooleanProperty and defaults to False.
checkbox_icon_normal
Background icon of the checkbox used for the default graphical representation when the checkbox is not
pressed.
checkbox_icon_normal is a StringProperty and defaults to ‘checkbox-blank-outline’.
checkbox_icon_down
Background icon of the checkbox used for the default graphical representation when the checkbox is
pressed.
checkbox_icon_down is a StringProperty and defaults to ‘checkbox-marked-outline’.
radio_icon_normal
Background icon (when using the group option) of the checkbox used for the default graphical represen-
tation when the checkbox is not pressed.
radio_icon_normal is a StringProperty and defaults to ‘checkbox-blank-circle-outline’.
radio_icon_down
Background icon (when using the group option) of the checkbox used for the default graphical represen-
tation when the checkbox is pressed.
radio_icon_down is a StringProperty and defaults to ‘checkbox-marked-circle-outline’.
selected_color
Selected color in rgba format.
selected_color is a ListProperty and defaults to [].
unselected_color
Unelected color in rgba format.
unselected_color is a ListProperty and defaults to [].
disabled_color
Disabled color in rgba format.
disabled_color is a ListProperty and defaults to [].
update_primary_color(self, instance, value)
update_icon(self, *args)
update_color(self, *args)
on_state(self, *args)
on_active(self, *args)
class kivymd.uix.selectioncontrol.MDSwitch(**kwargs)
This mixin class provides Button behavior. Please see the button behaviors module documentation
for more information.
Events
on_press Fired when the button is pressed.
on_release Fired when the button is released (i.e. the touch/click that pressed the button goes
away).
active
Indicates if the switch is active or inactive.
active is a BooleanProperty and defaults to False.
thumb_color
Get thumb color rgba format.
thumb_color is an AliasProperty and property is readonly.
thumb_color_disabled
Get thumb color disabled rgba format.
thumb_color_disabled is an AliasProperty and property is readonly.
thumb_color_down
Get thumb color down rgba format.
thumb_color_down is an AliasProperty and property is readonly.
on_size(self, *args)
See also:
Material Design spec, Image lists
SmartTileWithStar
KV = '''
<MyTile@SmartTileWithStar>
size_hint_y: None
height: "240dp"
ScrollView:
MDGridLayout:
cols: 3
adaptive_height: True
padding: dp(4), dp(4)
spacing: dp(4)
MyTile:
stars: 5
source: "cat-1.jpg"
MyTile:
stars: 5
source: "cat-2.jpg"
MyTile:
(continues on next page)
class MyApp(MDApp):
def build(self):
return Builder.load_string(KV)
MyApp().run()
SmartTileWithLabel
KV = '''
<MyTile@SmartTileWithStar>
size_hint_y: None
height: "240dp"
ScrollView:
MDGridLayout:
cols: 3
adaptive_height: True
padding: dp(4), dp(4)
spacing: dp(4)
MyTile:
source: "cat-1.jpg"
text: "[size=26]Cat 1[/size]\n[size=14]cat-1.jpg[/size]"
MyTile:
source: "cat-2.jpg"
text: "[size=26]Cat 2[/size]\n[size=14]cat-2.jpg[/size]"
tile_text_color: app.theme_cls.accent_color
MyTile:
source: "cat-3.jpg"
text: "[size=26][color=#ffffff]Cat 3[/color][/size]\n[size=14]cat-3.jpg[/
˓→size]"
tile_text_color: app.theme_cls.accent_color
'''
class MyApp(MDApp):
def build(self):
return Builder.load_string(KV)
API - kivymd.uix.imagelist
class kivymd.uix.imagelist.SmartTile(**kwargs)
A tile for more complex needs.
Includes an image, a container to place overlays and a box that can act as a header or a footer, as described in
the Material Design specs.
box_color
Sets the color and opacity for the information box.
box_color is a ListProperty and defaults to (0, 0, 0, 0.5).
box_position
Determines wether the information box acts as a header or footer to the image. Available are options:
‘footer’, ‘header’.
box_position is a OptionProperty and defaults to ‘footer’.
lines
Number of lines in the header/footer. As per Material Design specs, only 1 and 2 are valid values. Avail-
able are options: 1, 2.
lines is a OptionProperty and defaults to 1.
overlap
Determines if the header/footer overlaps on top of the image or not.
overlap is a BooleanProperty and defaults to True.
source
Path to tile image. See source.
source is a StringProperty and defaults to ‘’.
reload(self )
class kivymd.uix.imagelist.SmartTileWithLabel(**kwargs)
A tile for more complex needs.
Includes an image, a container to place overlays and a box that can act as a header or a footer, as described in
the Material Design specs.
font_style
Tile font style.
font_style is a StringProperty and defaults to ‘Caption’.
tile_text_color
Tile text color in rgba format.
tile_text_color is a StringProperty and defaults to (1, 1, 1, 1).
text
Determines the text for the box footer/header.
text is a StringProperty and defaults to ‘’.
class kivymd.uix.imagelist.SmartTileWithStar(**kwargs)
A tile for more complex needs.
Includes an image, a container to place overlays and a box that can act as a header or a footer, as described in
the Material Design specs.
stars
Tile stars.
stars is a NumericProperty and defaults to 1.
on_stars(self, *args)
Example
Builder.load_string('''
<ItemForList>
text: root.text
IconLeftSampleWidget:
icon: root.icon
<Example@FloatLayout>
BoxLayout:
orientation: 'vertical'
MDToolbar:
title: app.title
(continues on next page)
MDScrollViewRefreshLayout:
id: refresh_layout
refresh_callback: app.refresh_callback
root_layout: root
MDGridLayout:
id: box
adaptive_height: True
cols: 1
''')
class ItemForList(OneLineIconListItem):
icon = StringProperty()
class Example(MDApp):
title = 'Example Refresh Layout'
screen = None
x = 0
y = 15
def build(self):
self.screen = Factory.Example()
self.set_list()
return self.screen
def set_list(self):
async def set_list():
names_icons_list = list(md_icons.keys())[self.x:self.y]
for name_icon in names_icons_list:
await asynckivy.sleep(0)
self.screen.ids.box.add_widget(
ItemForList(icon=name_icon, text=name_icon))
asynckivy.start(set_list())
def refresh_callback(interval):
self.screen.ids.box.clear_widgets()
if self.x == 0:
self.x, self.y = 15, 30
else:
self.x, self.y = 0, 15
self.set_list()
(continues on next page)
Clock.schedule_once(refresh_callback, 1)
Example().run()
API - kivymd.uix.refreshlayout
class kivymd.uix.refreshlayout.MDScrollViewRefreshLayout(**kargs)
ScrollView class. See module documentation for more information.
Events
on_scroll_start Generic event fired when scrolling starts from touch.
on_scroll_move Generic event fired when scrolling move from touch.
on_scroll_stop Generic event fired when scrolling stops from touch.
Changed in version 1.9.0: on_scroll_start, on_scroll_move and on_scroll_stop events are now dispatched when
scrolling to handle nested ScrollViews.
Changed in version 1.7.0: auto_scroll, scroll_friction, scroll_moves, scroll_stoptime’ has been deprecated, use
:attr:`effect_cls instead.
root_layout
The spinner will be attached to this layout.
on_touch_up(self, *args)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
refresh_done(self )
class kivymd.uix.refreshlayout.RefreshSpinner(**kwargs)
Float layout class. See module documentation for more information.
spinner_color
start_anim_spinner(self )
hide_anim_spinner(self )
set_spinner(self, *args)
See also:
Material Design spec, Text fields
Note: MDTextField inherited from TextInput. Therefore, most parameters and all events of the TextInput
class are also available in the MDTextField class.
MDTextField
MDTextField:
hint_text: "No helper text"
MDTextField:
hint_text: "Helper text on focus"
helper_text: "This will disappear when you click off"
helper_text_mode: "on_focus"
MDTextField:
hint_text: "Persistent helper text"
helper_text: "Text is always here"
helper_text_mode: "persistent"
To display an error in a text field when using the helper_text_mode: "on_error" parameter, set the “error”
text field parameter to True:
from kivy.lang import Builder
KV = '''
BoxLayout:
padding: "10dp"
MDTextField:
id: text_field_error
hint_text: "Helper text on error (press 'Enter')"
helper_text: "There will always be a mistake"
helper_text_mode: "on_error"
pos_hint: {"center_y": .5}
'''
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
def build(self):
self.screen.ids.text_field_error.bind(
on_text_validate=self.set_error_message,
on_focus=self.set_error_message,
)
return self.screen
Test().run()
MDTextField:
hint_text: "required = True"
required: True
helper_text_mode: "on_error"
helper_text: "Enter text"
MDTextField:
hint_text: "Max text length = 5"
max_text_length: 5
MDTextField:
multiline: True
hint_text: "Multi-line text"
Color mode
MDTextField:
hint_text: "color_mode = 'accent'"
color_mode: 'accent'
MDTextField:
hint_text: "color_mode = 'custom'"
color_mode: 'custom'
helper_text_mode: "on_focus"
helper_text: "Color is defined by 'line_color_focus' property"
line_color_focus: 1, 0, 1, 1
MDTextField:
hint_text: "Line color normal"
line_color_normal: app.theme_cls.accent_color
Rectangle mode
MDTextField:
hint_text: "Rectangle mode"
mode: "rectangle"
Fill mode
MDTextField:
hint_text: "Fill mode"
mode: "fill"
fill_color: 0, 0, 0, .4
MDTextFieldRect
Note: MDTextFieldRect inherited from TextInput. You can use all parameters and attributes of the
TextInput class in the MDTextFieldRect class.
MDTextFieldRect:
size_hint: 1, None
height: "30dp"
MDTextFieldRound
Without icon
MDTextFieldRound:
hint_text: 'Empty field'
Warning: The icons in the MDTextFieldRound are static. You cannot bind events to them.
MDTextFieldRound:
icon_left: "email"
hint_text: "Field with left icon"
MDTextFieldRound:
icon_left: 'key-variant'
icon_right: 'eye-off'
hint_text: 'Field with left and right icons'
MDTextFieldRound:
icon_left: 'key-variant'
normal_color: app.theme_cls.accent_color
MDTextFieldRound:
icon_left: 'key-variant'
normal_color: app.theme_cls.accent_color
color_active: 1, 0, 0, 1
KV = '''
<ClickableTextFieldRound>:
size_hint_y: None
height: text_field.height
MDTextFieldRound:
id: text_field
hint_text: root.hint_text
text: root.text
password: True
color_active: app.theme_cls.primary_light
icon_left: "key-variant"
padding:
self._lbl_icon_left.texture_size[1] + dp(10) if self.icon_left else
˓→dp(15), (self.height / 2) - (self.line_height / 2),
˓→self._lbl_icon_right.texture_size[1] + dp(20), 0
MDIconButton:
icon: "eye-off"
ripple_scale: .5
pos_hint: {"center_y": .5}
pos: text_field.width - self.width + dp(8), 0
on_release:
self.icon = "eye" if self.icon == "eye-off" else "eye-off"
text_field.password = False if text_field.password is True else True
MDScreen:
ClickableTextFieldRound:
size_hint_x: None
width: "300dp"
(continues on next page)
class ClickableTextFieldRound(MDRelativeLayout):
text = StringProperty()
hint_text = StringProperty()
# Here specify the required parameters for MDTextFieldRound:
# [...]
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
Note: The icon on the right is available for use in all text fields.
MDTextField:
hint_text: "Name"
mode: "fill"
fill_color: 0, 0, 0, .4
icon_right: "arrow-down-drop-circle-outline"
icon_right_color: app.theme_cls.primary_color
MDTextField:
hint_text: "Name"
icon_right: "arrow-down-drop-circle-outline"
icon_right_color: app.theme_cls.primary_color
MDTextField:
hint_text: "Name"
mode: "rectangle"
icon_right: "arrow-down-drop-circle-outline"
icon_right_color: app.theme_cls.primary_color
See also:
See more information in the MDTextFieldRect class.
API - kivymd.uix.textfield
class kivymd.uix.textfield.MDTextFieldRect(**kwargs)
TextInput class. See module documentation for more information.
Events
on_text_validate Fired only in multiline=False mode when the user hits ‘enter’. This will also
unfocus the textinput.
on_double_tap Fired when a double tap happens in the text input. The default behavior selects
the text around the cursor position. More info at on_double_tap().
on_triple_tap Fired when a triple tap happens in the text input. The default behavior selects the
line around the cursor position. More info at on_triple_tap().
on_quad_touch Fired when four fingers are touching the text input. The default behavior selects
the whole text. More info at on_quad_touch().
Warning: When changing a TextInput property that requires re-drawing, e.g. modifying the text, the
updates occur on the next clock cycle and not instantly. This might cause any changes to the TextInput
that occur between the modification and the next cycle to be ignored, or to use previous values. For example,
after a update to the text, changing the cursor in the same clock frame will move it using the previous text
and will likely end up in an incorrect position. The solution is to schedule any updates to occur on the next
clock cycle using schedule_once().
Note: Selection is cancelled when TextInput is focused. If you need to show selection when TextInput is fo-
cused, you should delay (use Clock.schedule) the call to the functions for selecting text (select_all, select_text).
on_double_tap Fired when a double tap happens in the text input. The default behavior selects
the text around the cursor position. More info at on_double_tap().
on_triple_tap Fired when a triple tap happens in the text input. The default behavior selects the
line around the cursor position. More info at on_triple_tap().
on_quad_touch Fired when four fingers are touching the text input. The default behavior selects
the whole text. More info at on_quad_touch().
Warning: When changing a TextInput property that requires re-drawing, e.g. modifying the text, the
updates occur on the next clock cycle and not instantly. This might cause any changes to the TextInput
that occur between the modification and the next cycle to be ignored, or to use previous values. For example,
after a update to the text, changing the cursor in the same clock frame will move it using the previous text
and will likely end up in an incorrect position. The solution is to schedule any updates to occur on the next
clock cycle using schedule_once().
Note: Selection is cancelled when TextInput is focused. If you need to show selection when TextInput is fo-
cused, you should delay (use Clock.schedule) the call to the functions for selecting text (select_all, select_text).
on_text_validate Fired only in multiline=False mode when the user hits ‘enter’. This will also
unfocus the textinput.
on_double_tap Fired when a double tap happens in the text input. The default behavior selects
the text around the cursor position. More info at on_double_tap().
on_triple_tap Fired when a triple tap happens in the text input. The default behavior selects the
line around the cursor position. More info at on_triple_tap().
on_quad_touch Fired when four fingers are touching the text input. The default behavior selects
the whole text. More info at on_quad_touch().
Warning: When changing a TextInput property that requires re-drawing, e.g. modifying the text, the
updates occur on the next clock cycle and not instantly. This might cause any changes to the TextInput
that occur between the modification and the next cycle to be ignored, or to use previous values. For example,
after a update to the text, changing the cursor in the same clock frame will move it using the previous text
and will likely end up in an incorrect position. The solution is to schedule any updates to occur on the next
clock cycle using schedule_once().
Note: Selection is cancelled when TextInput is focused. If you need to show selection when TextInput is fo-
cused, you should delay (use Clock.schedule) the call to the functions for selecting text (select_all, select_text).
color_active
Field color if focus is True.
color_active is an ListProperty and defaults to [].
on_focus(self, instance, value)
on_icon_left(self, instance, value)
on_icon_left_color(self, instance, value)
on_icon_right(self, instance, value)
on_icon_right_color(self, instance, value)
on_color_active(self, instance, value)
2.3.24 Slider
See also:
Material Design spec, Sliders
KV = '''
Screen
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
MDSlider:
min: 0
max: 100
value: 40
hint: False
MDSlider:
min: 0
max: 100
value: 40
hint: False
humb_color_down: app.theme_cls.accent_color
API - kivymd.uix.slider
class kivymd.uix.slider.MDSlider(**kwargs)
Class for creating a Slider widget.
Check module documentation for more details.
active
If the slider is clicked.
active is an BooleanProperty and defaults to False.
hint
If True, then the current value is displayed above the slider.
hint is an BooleanProperty and defaults to True.
hint_bg_color
Hint rectangle color in rgba format.
hint_bg_color is an ListProperty and defaults to [].
hint_text_color
Hint text color in rgba format.
hint_text_color is an ListProperty and defaults to [].
hint_radius
Hint radius.
hint_radius is an NumericProperty and defaults to 4.
show_off
Show the ‘off’ ring when set to minimum value.
show_off is an BooleanProperty and defaults to True.
thumb_color
Current color slider in rgba format.
thumb_color is an AliasProperty that returns the value of the current color slider, property is
readonly.
thumb_color_down
Color slider in rgba format.
thumb_color_down is an AliasProperty that returns and set the value of color slider.
on_hint(self, instance, value)
on_value_normalized(self, *args)
When the value == min set it to ‘off’ state and make slider a ring.
on_show_off(self, *args)
on__is_off(self, *args)
on_active(self, *args)
on_touch_down(self, touch)
Receive a touch down event.
Parameters
touch: MotionEvent class Touch received. The touch is in parent coordinates. See
relativelayout for a discussion on coordinate systems.
Returns bool If True, the dispatching of the touch event will stop. If False, the event will
continue to be dispatched to the rest of the widget tree.
on_touch_up(self, touch)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
2.3.25 List
See also:
Material Design spec, Lists
The class MDList in combination with a BaseListItem like OneLineListItem will create a list that expands
as items are added to it, working nicely with Kivy’s ScrollView.
Due to the variety in sizes and controls in the Material Design spec, this module suffers from a certain level of
complexity to keep the widgets compliant, flexible and performant.
For this KivyMD provides list items that try to cover the most common usecases, when those are insufficient, there’s
a base class called BaseListItem which you can use to create your own list items. This documentation will only
cover the provided ones, for custom implementations please refer to this module’s source code.
KivyMD provides the following list items classes for use:
• OneLineListItem
• TwoLineListItem
• ThreeLineListItem
These widgets will take other widgets that inherit from ILeftBody, ILeftBodyTouch, IRightBody or
IRightBodyTouch and put them in their corresponding container.
As the name implies, ILeftBody and IRightBody will signal that the widget goes into the left or right container,
respectively.
ILeftBodyTouch and IRightBodyTouch do the same thing, except these widgets will also receive touch events
that occur within their surfaces.
KivyMD provides base classes such as ImageLeftWidget, ImageRightWidget, IconRightWidget,
IconLeftWidget, based on the above classes.
• OneLineAvatarListItem
• TwoLineAvatarListItem
• ThreeLineAvatarListItem
• OneLineIconListItem
• TwoLineIconListItem
• ThreeLineIconListItem
It allows the use of elements with custom widgets on the left and the right.
• OneLineAvatarIconListItem
• TwoLineAvatarIconListItem
• ThreeLineAvatarIconListItem
Usage
KV = '''
ScrollView:
MDList:
id: container
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
def on_start(self):
for i in range(20):
(continues on next page)
Test().run()
Events of List
KV = '''
ScrollView:
MDList:
OneLineAvatarIconListItem:
on_release: print("Click!")
IconLeftWidget:
icon: "github"
OneLineAvatarIconListItem:
on_release: print("Click 2!")
IconLeftWidget:
icon: "gitlab"
'''
class MainApp(MDApp):
def build(self):
return Builder.load_string(KV)
MainApp().run()
OneLineListItem
OneLineListItem:
text: "Single-line item"
TwoLineListItem
TwoLineListItem:
text: "Two-line item"
secondary_text: "Secondary text here"
ThreeLineListItem
ThreeLineListItem:
text: "Three-line item"
secondary_text: "This is a multi-line label where you can"
tertiary_text: "fit more text than usual"
OneLineAvatarListItem
OneLineAvatarListItem:
text: "Single-line item with avatar"
ImageLeftWidget:
source: "data/logo/kivy-icon-256.png"
TwoLineAvatarListItem
TwoLineAvatarListItem:
text: "Two-line item with avatar"
secondary_text: "Secondary text here"
ImageLeftWidget:
source: "data/logo/kivy-icon-256.png"
ThreeLineAvatarListItem
ThreeLineAvatarListItem:
text: "Three-line item with avatar"
secondary_text: "Secondary text here"
tertiary_text: "fit more text than usual"
ImageLeftWidget:
source: "data/logo/kivy-icon-256.png"
OneLineIconListItem
OneLineAvatarListItem:
text: "Single-line item with avatar"
IconLeftWidget:
icon: "language-python"
TwoLineIconListItem
TwoLineIconListItem:
text: "Two-line item with avatar"
secondary_text: "Secondary text here"
IconLeftWidget:
icon: "language-python"
ThreeLineIconListItem
ThreeLineIconListItem:
text: "Three-line item with avatar"
secondary_text: "Secondary text here"
tertiary_text: "fit more text than usual"
IconLeftWidget:
icon: "language-python"
OneLineAvatarIconListItem
OneLineAvatarIconListItem:
text: "One-line item with avatar"
IconLeftWidget:
icon: "plus"
IconRightWidget:
icon: "minus"
TwoLineAvatarIconListItem
TwoLineAvatarIconListItem:
text: "Two-line item with avatar"
secondary_text: "Secondary text here"
IconLeftWidget:
icon: "plus"
IconRightWidget:
icon: "minus"
ThreeLineAvatarIconListItem
ThreeLineAvatarIconListItem:
text: "Three-line item with avatar"
secondary_text: "Secondary text here"
tertiary_text: "fit more text than usual"
IconLeftWidget:
icon: "plus"
IconRightWidget:
icon: "minus"
KV = '''
<ListItemWithCheckbox>:
IconLeftWidget:
icon: root.icon
RightCheckbox:
BoxLayout:
ScrollView:
MDList:
id: scroll
'''
class ListItemWithCheckbox(OneLineAvatarIconListItem):
'''Custom list item.'''
icon = StringProperty("android")
class MainApp(MDApp):
def build(self):
return Builder.load_string(KV)
def on_start(self):
icons = list(md_icons.keys())
for i in range(30):
self.root.ids.scroll.add_widget(
ListItemWithCheckbox(text=f"Item {i}", icon=icons[i])
)
MainApp().run()
KV = '''
OneLineAvatarIconListItem:
text: "One-line item with avatar"
on_size:
self.ids._right_container.width = container.width
self.ids._right_container.x = container.width
IconLeftWidget:
icon: "cog"
Container:
id: container
MDIconButton:
icon: "minus"
MDIconButton:
icon: "plus"
'''
class MainApp(MDApp):
def build(self):
return Builder.load_string(KV)
MainApp().run()
API - kivymd.uix.list
class kivymd.uix.list.MDList(**kwargs)
ListItem container. Best used in conjunction with a kivy.uix.ScrollView.
When adding (or removing) a widget, it will resize itself to fit its children, plus top and bottom paddings as
described by the MD spec.
add_widget(self, widget, index=0, canvas=None)
Add a new widget as a child of this widget.
Parameters
widget: Widget Widget to add to our list of children.
index: int, defaults to 0 Index to insert the widget in the list. Notice that the default
of 0 means the widget is inserted at the beginning of the list and will thus be drawn
on top of other sibling widgets. For a full discussion of the index and widget hier-
archy, please see the Widgets Programming Guide.
New in version 1.0.5.
canvas: str, defaults to None Canvas to add widget’s canvas to. Can be ‘before’,
‘after’ or None for the default canvas.
New in version 1.9.0.
remove_widget(self, widget)
Remove a widget from the children of this widget.
Parameters
widget: Widget Widget to remove from our children list.
class kivymd.uix.list.BaseListItem(**kwargs)
Base class to all ListItems. Not supposed to be instantiated on its own.
text
Text shown in the first line.
text is a StringProperty and defaults to ‘’.
text_color
Text color in rgba format used if theme_text_color is set to ‘Custom’.
text_color is a ListProperty and defaults to None.
font_style
Text font style. See kivymd.font_definitions.py.
class kivymd.uix.list.ILeftBodyTouch
Same as ILeftBody, but allows the widget to receive touch events instead of triggering the ListItem’s ripple
effect.
class kivymd.uix.list.IRightBody
Pseudo-interface for widgets that go in the right container for ListItems that support it.
Implements nothing and requires no implementation, for annotation only.
class kivymd.uix.list.IRightBodyTouch
Same as IRightBody, but allows the widget to receive touch events instead of triggering the ListItem’s
ripple effect
class kivymd.uix.list.ContainerSupport
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
add_widget(self, widget, index=0)
remove_widget(self, widget)
on_touch_down(self, touch)
on_touch_move(self, touch, *args)
on_touch_up(self, touch)
propagate_touch_to_touchable_widgets(self, touch, touch_event, *args)
class kivymd.uix.list.OneLineListItem(**kwargs)
A one line list item.
class kivymd.uix.list.TwoLineListItem(**kwargs)
A two line list item.
class kivymd.uix.list.ThreeLineListItem(**kwargs)
A three line list item.
class kivymd.uix.list.OneLineAvatarListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.TwoLineAvatarListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.ThreeLineAvatarListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.OneLineIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.TwoLineIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.ThreeLineIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.OneLineRightIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.TwoLineRightIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.ThreeLineRightIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.OneLineAvatarIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.TwoLineAvatarIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.ThreeLineAvatarIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.ImageLeftWidget(**kwargs)
Pseudo-interface for widgets that go in the left container for ListItems that support it.
Implements nothing and requires no implementation, for annotation only.
class kivymd.uix.list.ImageRightWidget(**kwargs)
Same as IRightBody, but allows the widget to receive touch events instead of triggering the ListItem’s
ripple effect
class kivymd.uix.list.IconRightWidget(**kwargs)
Same as IRightBody, but allows the widget to receive touch events instead of triggering the ListItem’s
ripple effect
class kivymd.uix.list.IconLeftWidget(**kwargs)
Same as ILeftBody, but allows the widget to receive touch events instead of triggering the ListItem’s ripple
effect.
class kivymd.uix.list.CheckboxLeftWidget(**kwargs)
Same as ILeftBody, but allows the widget to receive touch events instead of triggering the ListItem’s ripple
effect.
2.3.26 Label
• MDLabel
• MDIcon
MDLabel
Class MDLabel inherited from the Label class but for MDLabel the text_size parameter is (self.width,
None) and default is positioned on the left:
KV = '''
Screen:
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "MDLabel"
MDLabel:
text: "MDLabel"
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
MDLabel:
text: "MDLabel"
halign: "center"
MDLabel color:
KV = '''
Screen:
BoxLayout:
id: box
orientation: "vertical"
MDToolbar:
title: "MDLabel"
'''
class Test(MDApp):
def build(self):
screen = Builder.load_string(KV)
# Names of standard color themes.
for name_theme in [
"Primary",
"Secondary",
"Hint",
"Error",
"ContrastParentBackground",
]:
screen.ids.box.add_widget(
MDLabel(
text=name_theme,
halign="center",
theme_text_color=name_theme,
)
)
return screen
Test().run()
To use a custom color for MDLabel, use a theme ‘Custom’. After that, you can specify the desired color in the rgba
format in the text_color parameter:
MDLabel:
text: "Custom color"
halign: "center"
theme_text_color: "Custom"
text_color: 0, 0, 1, 1
MDLabel provides standard font styles for labels. To do this, specify the name of the desired style in the
font_style parameter:
from kivy.lang import Builder
KV = '''
Screen:
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "MDLabel"
ScrollView:
MDList:
id: box
'''
class Test(MDApp):
def build(self):
screen = Builder.load_string(KV)
(continues on next page)
Test().run()
MDIcon
You can use labels to display material design icons using the MDIcon class.
See also:
Material Design Icons
Material Design Icon Names
The MDIcon class is inherited from MDLabel and has the same parameters.
Warning: For the MDIcon class, you cannot use text and font_style options!
MDIcon:
halign: "center"
icon: "language-python"
API - kivymd.uix.label
class kivymd.uix.label.MDLabel(**kwargs)
Label class, see module documentation for more information.
Events
on_ref_press Fired when the user clicks on a word referenced with a [ref] tag in a text
markup.
font_style
Label font style.
Available options are: ‘H1’, ‘H2’, ‘H3’, ‘H4’, ‘H5’, ‘H6’, ‘Subtitle1’, ‘Subtitle2’, ‘Body1’, ‘Body2’,
‘Button’, ‘Caption’, ‘Overline’, ‘Icon’.
font_style is an OptionProperty and defaults to ‘Body1’.
text
Text of the label.
theme_text_color
Label color scheme name.
Available options are: ‘Primary’, ‘Secondary’, ‘Hint’, ‘Error’, ‘Custom’, ‘ContrastParentBackground’.
theme_text_color is an OptionProperty and defaults to None.
text_color
Label text color in rgba format.
text_color is an ListProperty and defaults to None.
parent_background
can_capitalize
update_font_style(self, *args)
on_theme_text_color(self, instance, value)
on_text_color(self, *args)
on_opposite_colors(self, instance, value)
class kivymd.uix.label.MDIcon(**kwargs)
Label class, see module documentation for more information.
Events
on_ref_press Fired when the user clicks on a word referenced with a [ref] tag in a text
markup.
icon
Label icon name.
icon is an StringProperty and defaults to ‘android’.
source
Path to icon.
source is an StringProperty and defaults to None.
2.3.27 Card
See also:
Material Design spec, Cards
Note: MDCard inherited from BoxLayout. You can use all parameters and attributes of the BoxLayout class in
the MDCard class.
MDCard
KV = '''
Screen:
MDCard:
size_hint: None, None
size: "280dp", "180dp"
pos_hint: {"center_x": .5, "center_y": .5}
'''
class TestCard(MDApp):
def build(self):
return Builder.load_string(KV)
TestCard().run()
KV = '''
Screen:
MDCard:
orientation: "vertical"
padding: "8dp"
size_hint: None, None
size: "280dp", "180dp"
pos_hint: {"center_x": .5, "center_y": .5}
MDLabel:
text: "Title"
theme_text_color: "Secondary"
size_hint_y: None
height: self.texture_size[1]
MDSeparator:
height: "1dp"
MDLabel:
(continues on next page)
class TestCard(MDApp):
def build(self):
return Builder.load_string(KV)
TestCard().run()
MDCardSwipe
To create a card with swipe-to-delete behavior, you must create a new class that inherits from the MDCardSwipe
class:
<SwipeToDeleteItem>:
size_hint_y: None
height: content.height
MDCardSwipeLayerBox:
MDCardSwipeFrontBox:
OneLineListItem:
id: content
text: root.text
_no_ripple_effect: True
class SwipeToDeleteItem(MDCardSwipe):
text = StringProperty()
KV = '''
<SwipeToDeleteItem>:
size_hint_y: None
height: content.height
MDCardSwipeLayerBox:
# Content under the card.
MDCardSwipeFrontBox:
# Content of card.
OneLineListItem:
id: content
text: root.text
_no_ripple_effect: True
Screen:
BoxLayout:
orientation: "vertical"
spacing: "10dp"
MDToolbar:
elevation: 10
title: "MDCardSwipe"
ScrollView:
scroll_timeout : 100
MDList:
id: md_list
padding: 0
'''
class SwipeToDeleteItem(MDCardSwipe):
'''Card with `swipe-to-delete` behavior.'''
text = StringProperty()
class TestCard(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
def build(self):
return self.screen
(continues on next page)
def on_start(self):
'''Creates a list of cards.'''
for i in range(20):
self.screen.ids.md_list.add_widget(
SwipeToDeleteItem(text=f"One-line item {i}")
)
TestCard().run()
<SwipeToDeleteItem>:
# By default, the parameter is "left"
anchor: "right"
Swipe behavior
<SwipeToDeleteItem>:
# By default, the parameter is "hand"
type_swipe: "hand"
<SwipeToDeleteItem>:
type_swipe: "auto"
The map provides the MDCardSwipe.on_swipe_complete event. You can use this event to remove items from
a list:
<SwipeToDeleteItem>:
on_swipe_complete: app.on_swipe_complete(root)
KV = '''
<SwipeToDeleteItem>:
size_hint_y: None
height: content.height
type_swipe: "auto"
on_swipe_complete: app.on_swipe_complete(root)
MDCardSwipeLayerBox:
MDCardSwipeFrontBox:
OneLineListItem:
id: content
text: root.text
_no_ripple_effect: True
Screen:
BoxLayout:
orientation: "vertical"
spacing: "10dp"
MDToolbar:
elevation: 10
title: "MDCardSwipe"
ScrollView:
MDList:
id: md_list
padding: 0
'''
class SwipeToDeleteItem(MDCardSwipe):
text = StringProperty()
class TestCard(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
def build(self):
return self.screen
def on_start(self):
for i in range(20):
self.screen.ids.md_list.add_widget(
SwipeToDeleteItem(text=f"One-line item {i}")
)
TestCard().run()
To add content to the bottom layer of the card, use the MDCardSwipeLayerBox class.
<SwipeToDeleteItem>:
MDCardSwipeLayerBox:
padding: "8dp"
MDIconButton:
icon: "trash-can"
pos_hint: {"center_y": .5}
on_release: app.remove_item(root)
KV = '''
<SwipeToDeleteItem>:
size_hint_y: None
height: content.height
MDCardSwipeLayerBox:
padding: "8dp"
MDIconButton:
icon: "trash-can"
pos_hint: {"center_y": .5}
on_release: app.remove_item(root)
MDCardSwipeFrontBox:
OneLineListItem:
id: content
text: root.text
_no_ripple_effect: True
(continues on next page)
Screen:
BoxLayout:
orientation: "vertical"
spacing: "10dp"
MDToolbar:
elevation: 10
title: "MDCardSwipe"
ScrollView:
MDList:
id: md_list
padding: 0
'''
class SwipeToDeleteItem(MDCardSwipe):
text = StringProperty()
class TestCard(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
def build(self):
return self.screen
def on_start(self):
for i in range(20):
self.screen.ids.md_list.add_widget(
SwipeToDeleteItem(text=f"One-line item {i}")
)
TestCard().run()
Focus behavior
MDCard:
focus_behavior: True
Ripple behavior
MDCard:
ripple_behavior: True
KV = '''
<StarButton@MDIconButton>
icon: "star"
on_release: self.icon = "star-outline" if self.icon == "star" else "star"
Screen:
MDCard:
orientation: "vertical"
size_hint: .5, None
height: box_top.height + box_bottom.height
focus_behavior: True
ripple_behavior: True
pos_hint: {"center_x": .5, "center_y": .5}
MDBoxLayout:
id: box_top
spacing: "20dp"
adaptive_height: True
FitImage:
source: "/Users/macbookair/album.jpeg"
size_hint: .3, None
height: text_box.height
MDBoxLayout:
id: text_box
orientation: "vertical"
adaptive_height: True
spacing: "10dp"
padding: 0, "10dp", "10dp", "10dp"
MDLabel:
text: "July 27, 1984"
size_hint_y: None
height: self.texture_size[1]
theme_text_color: "Primary"
MDSeparator:
MDBoxLayout:
id: box_bottom
adaptive_height: True
padding: "10dp", 0, 0, 0
MDLabel:
text: "Rate this album"
size_hint_y: None
height: self.texture_size[1]
pos_hint: {"center_y": .5}
theme_text_color: "Primary"
StarButton:
StarButton:
StarButton:
StarButton:
StarButton:
'''
class Test(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
return Builder.load_string(KV)
Test().run()
API - kivymd.uix.card
class kivymd.uix.card.MDSeparator(**kwargs)
A separator line.
color
Separator color in rgba format.
color is a ListProperty and defaults to [].
on_orientation(self, *args)
class kivymd.uix.card.MDCard(**kwargs)
Widget class. See module documentation for more information.
Events
on_touch_down: (touch, ) Fired when a new touch event occurs. touch is the touch object.
on_touch_move: (touch, ) Fired when an existing touch moves. touch is the touch object.
on_touch_up: (touch, ) Fired when an existing touch disappears. touch is the touch object.
on_kv_post: (base_widget, ) Fired after all the kv rules associated with the widget and all other
widgets that are in any of those rules have had all their kv rules applied. base_widget is
the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated
from Python, e.g. MyWidget()).
Changed in version 1.11.0.
Warning: Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable
automatic garbage collection for instances of that class. This is because the Widget class creates reference
cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the EventDispatcher.
Event properties can now be used when contructing a simple class without subclassing Widget.
Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to
properties or events, as in the Kv language.
background
Background image path.
background is a StringProperty and defaults to ‘’.
focus_behavior
Using focus when hovering over a card.
focus_behavior is a BooleanProperty and defaults to False.
ripple_behavior
Use ripple effect for card.
ripple_behavior is a BooleanProperty and defaults to False.
elevation
Elevation value.
elevation is an NumericProperty and defaults to 1.
on_radius(self, instance, value)
class kivymd.uix.card.MDCardSwipe(**kw)
Events
open_progress
Percent of visible part of side panel. The percent is specified as a floating point number in the range 0-1.
0.0 if panel is closed and 1.0 if panel is opened.
open_progress is a NumericProperty and defaults to 0.0.
opening_transition
The name of the animation transition type to use when animating to the state ‘opened’.
opening_transition is a StringProperty and defaults to ‘out_cubic’.
closing_transition
The name of the animation transition type to use when animating to the state ‘closed’.
closing_transition is a StringProperty and defaults to ‘out_sine’.
anchor
Anchoring screen edge for card. Available options are: ‘left’, ‘right’.
anchor is a OptionProperty and defaults to left.
swipe_distance
The distance of the swipe with which the movement of navigation drawer begins.
swipe_distance is a NumericProperty and defaults to 50.
opening_time
The time taken for the card to slide to the state ‘open’.
opening_time is a NumericProperty and defaults to 0.2.
state
Detailed state. Sets before state. Bind to state instead of status. Available options are: ‘closed’,
‘opened’.
status is a OptionProperty and defaults to ‘closed’.
max_swipe_x
If, after the events of on_touch_up card position exceeds this value - will automatically execute the
method open_card, and if not - will automatically be close_card method.
max_swipe_x is a NumericProperty and defaults to 0.3.
max_opened_x
The value of the position the card shifts to when type_swipe s set to ‘hand’.
max_opened_x is a NumericProperty and defaults to 100dp.
type_swipe
Type of card opening when swipe. Shift the card to the edge or to a set position max_opened_x.
Available options are: ‘auto’, ‘hand’.
type_swipe is a OptionProperty and defaults to auto.
add_widget(self, widget, index=0, canvas=None)
Add a new widget as a child of this widget.
Parameters
widget: Widget Widget to add to our list of children.
index: int, defaults to 0 Index to insert the widget in the list. Notice that the default
of 0 means the widget is inserted at the beginning of the list and will thus be drawn
on top of other sibling widgets. For a full discussion of the index and widget hier-
archy, please see the Widgets Programming Guide.
New in version 1.0.5.
canvas: str, defaults to None Canvas to add widget’s canvas to. Can be ‘before’,
‘after’ or None for the default canvas.
New in version 1.9.0.
on_swipe_complete(self, *args)
Called when a swipe of card is completed.
on_anchor(self, instance, value)
on_open_progress(self, instance, value)
on_touch_move(self, touch)
Receive a touch move event. The touch is in parent coordinates.
See on_touch_down() for more information.
on_touch_up(self, touch)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
on_touch_down(self, touch)
Receive a touch down event.
Parameters
touch: MotionEvent class Touch received. The touch is in parent coordinates. See
relativelayout for a discussion on coordinate systems.
Returns bool If True, the dispatching of the touch event will stop. If False, the event will
continue to be dispatched to the rest of the widget tree.
complete_swipe(self )
open_card(self )
close_card(self )
class kivymd.uix.card.MDCardSwipeFrontBox(**kwargs)
Widget class. See module documentation for more information.
Events
on_touch_down: (touch, ) Fired when a new touch event occurs. touch is the touch object.
on_touch_move: (touch, ) Fired when an existing touch moves. touch is the touch object.
on_touch_up: (touch, ) Fired when an existing touch disappears. touch is the touch object.
on_kv_post: (base_widget, ) Fired after all the kv rules associated with the widget and all other
widgets that are in any of those rules have had all their kv rules applied. base_widget is
the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated
from Python, e.g. MyWidget()).
Changed in version 1.11.0.
Warning: Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable
automatic garbage collection for instances of that class. This is because the Widget class creates reference
cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the EventDispatcher.
Event properties can now be used when contructing a simple class without subclassing Widget.
Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to
properties or events, as in the Kv language.
class kivymd.uix.card.MDCardSwipeLayerBox(**kwargs)
Box layout class. See module documentation for more information.
2.3.28 Chip
See also:
Material Design spec, Chips
Usage
MDChip:
label: 'Coffee'
color: .4470588235118, .1960787254902, 0, 1
icon: 'coffee'
callback: app.callback_for_menu_items
The user function takes two arguments - the object and the text of the chip:
MDChip:
label: 'Kivy'
icon: 'data/logo/kivy-icon-256.png'
MDChip:
label: 'Without icon'
icon: ''
MDChip:
label: 'Check with icon'
icon: 'city'
check: True
Choose chip
MDChooseChip:
MDChip:
label: 'Earth'
icon: 'earth'
selected_chip_color: .21176470535294, .098039627451, 1, 1
MDChip:
label: 'Face'
icon: 'face'
selected_chip_color: .21176470535294, .098039627451, 1, 1
MDChip:
(continues on next page)
API - kivymd.uix.chip
class kivymd.uix.chip.MDChip(**kwargs)
Box layout class. See module documentation for more information.
label
Chip text.
label is an StringProperty and defaults to ‘’.
icon
Chip icon.
icon is an StringProperty and defaults to ‘checkbox-blank-circle’.
color
Chip color in rgba format.
color is an ListProperty and defaults to [].
text_color
Chip’s text color in rgba format.
text_color is an ListProperty and defaults to [].
check
If True, a checkmark is added to the left when touch to the chip.
check is an BooleanProperty and defaults to False.
callback
Custom method.
callback is an ObjectProperty and defaults to None.
radius
Corner radius values.
radius is an NumericProperty and defaults to ‘12dp’.
selected_chip_color
The color of the chip that is currently selected in rgba format.
selected_chip_color is an ListProperty and defaults to [].
on_icon(self, instance, value)
on_touch_down(self, touch)
Receive a touch down event.
Parameters
touch: MotionEvent class Touch received. The touch is in parent coordinates. See
relativelayout for a discussion on coordinate systems.
Returns bool If True, the dispatching of the touch event will stop. If False, the event will
continue to be dispatched to the rest of the widget tree.
class kivymd.uix.chip.MDChooseChip(**kwargs)
Stack layout class. See module documentation for more information.
add_widget(self, widget, index=0, canvas=None)
Add a new widget as a child of this widget.
Parameters
widget: Widget Widget to add to our list of children.
index: int, defaults to 0 Index to insert the widget in the list. Notice that the default
of 0 means the widget is inserted at the beginning of the list and will thus be drawn
on top of other sibling widgets. For a full discussion of the index and widget hier-
archy, please see the Widgets Programming Guide.
New in version 1.0.5.
canvas: str, defaults to None Canvas to add widget’s canvas to. Can be ‘before’,
‘after’ or None for the default canvas.
New in version 1.9.0.
Usage
path = '/' # path to the directory that will be opened in the file manager
file_manager = MDFileManager(
exit_manager=self.exit_manager, # function called when the user reaches
˓→directory tree root
Warning: The preview mode is intended only for viewing images and will not display other types of files.
Example
MDToolbar:
title: "MDFileManager"
left_action_items: [['menu', lambda x: None]]
elevation: 10
FloatLayout:
MDRoundFlatIconButton:
text: "Open manager"
icon: "folder"
pos_hint: {'center_x': .5, 'center_y': .6}
on_release: app.file_manager_open()
'''
class Example(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
Window.bind(on_keyboard=self.events)
self.manager_open = False
self.file_manager = MDFileManager(
exit_manager=self.exit_manager,
select_path=self.select_path,
preview=True,
)
def build(self):
return Builder.load_string(KV)
def file_manager_open(self):
self.file_manager.show('/') # output manager to the screen
self.manager_open = True
self.exit_manager()
toast(path)
self.manager_open = False
self.file_manager.close()
Example().run()
API - kivymd.uix.filemanager
class kivymd.uix.filemanager.MDFileManager(**kwargs)
Float layout class. See module documentation for more information.
icon
The icon that will be used on the directory selection button.
icon is an StringProperty and defaults to check.
icon_folder
The icon that will be used for folder icons when using preview = True.
icon is an StringProperty and defaults to check.
exit_manager
Function called when the user reaches directory tree root.
exit_manager is an ObjectProperty and defaults to lambda x: None.
select_path
Function, called when selecting a file/directory.
select_path is an ObjectProperty and defaults to lambda x: None.
ext
List of file extensions to be displayed in the manager. For example, [‘.py’, ‘.kv’] - will filter out all files,
except python scripts and Kv Language.
ext is an ListProperty and defaults to [].
search
It can take the values ‘all’ ‘dirs’ ‘files’ - display only directories or only files or both them. By default, it
displays folders, and files. Available options are: ‘all’, ‘dirs’, ‘files’.
search is an OptionProperty and defaults to all.
current_path
Current directory.
current_path is an StringProperty and defaults to /.
use_access
Show access to files and directories.
use_access is an BooleanProperty and defaults to True.
preview
Shows only image previews.
preview is an BooleanProperty and defaults to False.
show_hidden_files
Shows hidden files.
show_hidden_files is an BooleanProperty and defaults to False.
sort_by
It can take the values ‘nothing’ ‘name’ ‘date’ ‘size’ ‘type’ - sorts files by option By default, sort by name.
Available options are: ‘nothing’, ‘name’, ‘date’, ‘size’, ‘type’.
sort_by is an OptionProperty and defaults to name.
sort_by_desc
Sort by descending.
sort_by_desc is an BooleanProperty and defaults to False.
show(self, path)
Forms the body of a directory tree.
Parameters path – The path to the directory that will be opened in the file manager.
get_access_string(self, path)
get_content(self )
Returns a list of the type [[Folder List], [file list]].
close(self )
Closes the file manager window.
select_dir_or_file(self, path)
Called by tap on the name of the directory or file.
back(self )
Returning to the branch down in the directory tree.
select_directory_on_press_button(self, *args)
Called when a click on a floating button.
2.3.30 Tooltip
See also:
Material Design spec, Tooltips
Tooltips display informative text when users hover over, focus on, or tap an element.
To use the MDTooltip class, you must create a new class inherited from the MDTooltip class:
In Kv-language:
<TooltipMDIconButton@MDIconButton+MDTooltip>
In Python code:
Warning: MDTooltip only works correctly with button and label classes.
KV = '''
<TooltipMDIconButton@MDIconButton+MDTooltip>
Screen:
TooltipMDIconButton:
(continues on next page)
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
Note: The behavior of tooltips on desktop and mobile devices is different. For more detailed information, click here.
API - kivymd.uix.tooltip
class kivymd.uix.tooltip.MDTooltip(**kwargs)
Events
tooltip_bg_color
Tooltip background color in rgba format.
tooltip_bg_color is an ListProperty and defaults to [].
tooltip_text_color
Tooltip text color in rgba format.
tooltip_text_color is an ListProperty and defaults to [].
tooltip_text
Tooltip text.
tooltip_text is an StringProperty and defaults to ‘’.
padding
delete_clock(self, widget, touch, *args)
adjust_tooltip_position(self, x, y)
Returns the coordinates of the tooltip that fit into the borders of the screen.
display_tooltip(self, interval)
animation_tooltip_show(self, interval)
remove_tooltip(self, *args)
on_long_touch(self, touch, *args)
Called when the widget is pressed for a long time.
on_enter(self, *args)
See on_enter method in HoverBehavior class.
on_leave(self )
See on_leave method in HoverBehavior class.
class kivymd.uix.tooltip.MDTooltipViewClass(**kwargs)
Box layout class. See module documentation for more information.
tooltip_bg_color
See tooltip_bg_color.
tooltip_text_color
See tooltip_text_color.
tooltip_text
See tooltip_text.
2.3.31 Backdrop
See also:
Material Design spec, Backdrop
Usage
<Root>:
MDBackdrop:
MDBackdropBackLayer:
ContentForBackdropBackLayer:
MDBackdropFrontLayer:
(continues on next page)
ContentForBackdropFrontLayer:
Example
# Your layouts.
Builder.load_string(
'''
#:import Window kivy.core.window.Window
#:import IconLeftWidget kivymd.uix.list.IconLeftWidget
#:import images_path kivymd.images_path
<ItemBackdropFrontLayer@TwoLineAvatarListItem>
icon: "android"
IconLeftWidget:
icon: root.icon
<MyBackdropFrontLayer@ItemBackdropFrontLayer>
backdrop: None
text: "Lower the front layer"
secondary_text: " by 50 %"
icon: "transfer-down"
on_press: root.backdrop.open(-Window.height / 2)
pos_hint: {"top": 1}
_no_ripple_effect: True
<MyBackdropBackLayer@Image>
size_hint: .8, .8
source: f"{images_path}/kivymd.png"
pos_hint: {"center_x": .5, "center_y": .6}
'''
)
MDBackdrop:
id: backdrop
left_action_items: [['menu', lambda x: self.open()]]
title: "Example Backdrop"
header_text: "Menu:"
MDBackdropBackLayer:
(continues on next page)
MDBackdropFrontLayer:
MyBackdropFrontLayer:
backdrop: backdrop
'''
)
class ExampleBackdrop(Screen):
pass
class TestBackdrop(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def build(self):
return ExampleBackdrop()
TestBackdrop().run()
API - kivymd.uix.backdrop
class kivymd.uix.backdrop.MDBackdrop(**kwargs)
Events
padding
Padding for contents of the front layer.
padding is an ListProperty and defaults to [0, 0, 0, 0].
left_action_items
The icons and methods left of the kivymd.uix.toolbar.MDToolbar in back layer. For more infor-
mation, see the kivymd.uix.toolbar.MDToolbar module and left_action_items parame-
ter.
left_action_items is an ListProperty and defaults to [].
right_action_items
Works the same way as left_action_items.
right_action_items is an ListProperty and defaults to [].
title
See the kivymd.uix.toolbar.MDToolbar.title parameter.
title is an StringProperty and defaults to ‘’.
background_color
Background color of back layer.
background_color is an ListProperty and defaults to [].
radius
The value of the rounding radius of the upper left corner of the front layer.
radius is an NumericProperty and defaults to 25.
header
Whether to use a header above the contents of the front layer.
header is an BooleanProperty and defaults to True.
header_text
Text of header.
header_text is an StringProperty and defaults to ‘Header’.
close_icon
The name of the icon that will be installed on the toolbar on the left when opening the front layer.
close_icon is an StringProperty and defaults to ‘close’.
on_open(self )
When the front layer drops.
on_close(self )
When the front layer rises.
on_left_action_items(self, instance, value)
on_header(self, instance, value)
open(self, open_up_to=0)
Opens the front layer.
Open_up_to the height to which the front screen will be lowered; if equal to zero - falls to the
bottom of the screen;
close(self )
Opens the front layer.
animtion_icon_menu(self )
animtion_icon_close(self, instance_animation, instance_icon_menu)
add_widget(self, widget, index=0, canvas=None)
Add a new widget as a child of this widget.
Parameters
widget: Widget Widget to add to our list of children.
index: int, defaults to 0 Index to insert the widget in the list. Notice that the default
of 0 means the widget is inserted at the beginning of the list and will thus be drawn
on top of other sibling widgets. For a full discussion of the index and widget hier-
archy, please see the Widgets Programming Guide.
New in version 1.0.5.
canvas: str, defaults to None Canvas to add widget’s canvas to. Can be ‘before’,
‘after’ or None for the default canvas.
New in version 1.9.0.
class kivymd.uix.backdrop.MDBackdropToolbar(**kwargs)
Events
on_action_button Method for the button used for the MDBottomAppBar class.
class kivymd.uix.backdrop.MDBackdropFrontLayer(**kwargs)
Box layout class. See module documentation for more information.
class kivymd.uix.backdrop.MDBackdropBackLayer(**kwargs)
Box layout class. See module documentation for more information.
2.3.32 RelativeLayout
RelativeLayout class equivalent. Simplifies working with some widget properties. For example:
RelativeLayout
RelativeLayout:
canvas:
Color:
rgba: app.theme_cls.primary_color
RoundedRectangle:
pos: (0, 0)
size: self.size
radius: [25, ]
MDRelativeLayout
MDRelativeLayout:
radius: [25, ]
md_bg_color: app.theme_cls.primary_color
API - kivymd.uix.relativelayout
class kivymd.uix.relativelayout.MDRelativeLayout(**kw)
RelativeLayout class, see module documentation for more information.
2.3.33 StackLayout
StackLayout class equivalent. Simplifies working with some widget properties. For example:
StackLayout
StackLayout:
size_hint_y: None
height: self.minimum_height
canvas:
Color:
rgba: app.theme_cls.primary_color
Rectangle:
pos: self.pos
size: self.size
MDStackLayout
MDStackLayout:
adaptive_height: True
md_bg_color: app.theme_cls.primary_color
• adaptive_height
• adaptive_width
• adaptive_size
adaptive_height
adaptive_height: True
Equivalent
size_hint_y: None
height: self.minimum_height
adaptive_width
adaptive_width: True
Equivalent
size_hint_x: None
height: self.minimum_width
adaptive_size
adaptive_size: True
Equivalent
API - kivymd.uix.stacklayout
class kivymd.uix.stacklayout.MDStackLayout(**kwargs)
Stack layout class. See module documentation for more information.
2.3.34 Screen
Screen class equivalent. Simplifies working with some widget properties. For example:
Screen
Screen:
canvas:
Color:
rgba: app.theme_cls.primary_color
RoundedRectangle:
pos: self.pos
size: self.size
radius: [25, 0, 0, 0]
MDScreen
MDScreen:
radius: [25, 0, 0, 0]
md_bg_color: app.theme_cls.primary_color
API - kivymd.uix.screen
class kivymd.uix.screen.MDScreen(**kw)
Screen is an element intended to be used with a ScreenManager. Check module documentation for more
information.
Events
on_pre_enter: () Event fired when the screen is about to be used: the entering animation is
started.
on_enter: () Event fired when the screen is displayed: the entering animation is complete.
on_pre_leave: () Event fired when the screen is about to be removed: the leaving animation is
started.
on_leave: () Event fired when the screen is removed: the leaving animation is finished.
Changed in version 1.6.0: Events on_pre_enter, on_enter, on_pre_leave and on_leave were added.
2.3.35 DataTables
See also:
Material Design spec, DataTables
Warning: Data tables are still far from perfect. Errors are possible and we hope you inform us about them.
API - kivymd.uix.datatables
class kivymd.uix.datatables.MDDataTable(**kwargs)
Events
on_row_press Called when a table row is clicked.
on_check_press Called when the check box in the table row is checked.
class Example(MDApp):
def build(self):
self.data_tables = MDDataTable(
size_hint=(0.9, 0.6),
use_pagination=True,
check=True,
column_data=[
("No.", dp(30)),
("Column 1", dp(30)),
("Column 2", dp(30)),
("Column 3", dp(30)),
("Column 4", dp(30)),
("Column 5", dp(30)),
],
row_data=[
(f"{i + 1}", "2.23", "3.65", "44.1", "0.45", "62.5")
for i in range(50)
],
)
self.data_tables.bind(on_row_press=self.on_row_press)
self.data_tables.bind(on_check_press=self.on_check_press)
def on_start(self):
self.data_tables.open()
print(instance_table, instance_row)
print(instance_table, current_row)
Example().run()
column_data
Data for header columns.
class Example(MDApp):
def build(self):
self.data_tables = MDDataTable(
size_hint=(0.9, 0.6),
# name column, width column
column_data=[
("Column 1", dp(30)),
("Column 2", dp(30)),
("Column 3", dp(30)),
("Column 4", dp(30)),
("Column 5", dp(30)),
("Column 6", dp(30)),
],
)
def on_start(self):
self.data_tables.open()
Example().run()
class Example(MDApp):
(continues on next page)
def on_start(self):
self.data_tables.open()
Example().run()
class Example(MDApp):
def build(self):
self.data_tables = MDDataTable(
size_hint=(0.9, 0.6),
use_pagination=True,
column_data=[
("No.", dp(30)),
("Column 1", dp(30)),
("Column 2", dp(30)),
("Column 3", dp(30)),
("Column 4", dp(30)),
("Column 5", dp(30)),
],
row_data=[
(f"{i + 1}", "1", "2", "3", "4", "5") for i in range(50)
],
)
def on_start(self):
self.data_tables.open()
Example().run()
Center
Auto
140dp
240dp
2.3.36 TapTargetView
See also:
TapTargetView, GitHub
TapTargetView, Material archive
Provide value and improve engagement by introducing users to new features and functionality at
relevant moments.
Usage
KV = '''
Screen:
MDFloatingActionButton:
id: button
icon: "plus"
pos: 10, 10
on_release: app.tap_target_start()
'''
class TapTargetViewDemo(MDApp):
def build(self):
screen = Builder.load_string(KV)
self.tap_target_view = MDTapTargetView(
widget=screen.ids.button,
title_text="This is an add button",
description_text="This is a description of the button",
widget_position="left_bottom",
)
def tap_target_start(self):
if self.tap_target_view.state == "close":
self.tap_target_view.start()
else:
self.tap_target_view.stop()
TapTargetViewDemo().run()
Widget position
self.tap_target_view = MDTapTargetView(
...
widget_position="right",
)
self.tap_target_view = MDTapTargetView(
...
widget_position="left",
)
self.tap_target_view = MDTapTargetView(
...
widget_position="top",
)
self.tap_target_view = MDTapTargetView(
...
widget_position="bottom",
)
self.tap_target_view = MDTapTargetView(
...
widget_position="left_top",
)
self.tap_target_view = MDTapTargetView(
...
widget_position="right_top",
)
self.tap_target_view = MDTapTargetView(
...
widget_position="left_bottom",
)
self.tap_target_view = MDTapTargetView(
...
widget_position="right_bottom",
)
If you use the widget_position = "center" parameter then you must definitely specify the
title_position.
self.tap_target_view = MDTapTargetView(
...
widget_position="center",
title_position="left_top",
)
Text options
self.tap_target_view = MDTapTargetView(
...
title_text="Title text",
description_text="Description text",
)
You can use the following options to control font size, color, and boldness:
• title_text_size
• title_text_color
• title_text_bold
• description_text_size
• description_text_color
• description_text_bold
self.tap_target_view = MDTapTargetView(
...
title_text="Title text",
title_text_size="36sp",
description_text="Description text",
description_text_color=[1, 0, 0, 1]
)
self.tap_target_view = MDTapTargetView(
...
title_text="[size=36]Title text[/size]",
description_text="[color=#ff0000ff]Description text[/color]",
)
Events control
self.tap_target_view.bind(on_open=self.on_open, on_close=self.on_close)
print("Open", instance_tap_target_view)
print("Close", instance_tap_target_view)
API - kivymd.uix.taptargetview
class kivymd.uix.taptargetview.MDTapTargetView(**kwargs)
Rough try to mimic the working of Android’s TapTargetView.
Events
on_open Called at the time of the start of the widget opening animation.
on_close Called at the time of the start of the widget closed animation.
widget
Widget to add TapTargetView upon.
widget is an ObjectProperty and defaults to None.
outer_radius
Radius for outer circle.
self.tap_target_view = MDTapTargetView(
...
outer_circle_color=(1, 0, 0)
)
self.tap_target_view = MDTapTargetView(
...
target_circle_color=(1, 0, 0)
)
description_text_color
Text size for description text.
description_text_color is an ListProperty and defaults to [0.9, 0.9, 0.9, 1].
description_text_bold
Whether description should be bold.
description_text_bold is an BooleanProperty and defaults to False.
draw_shadow
Whether to show shadow.
draw_shadow is an BooleanProperty and defaults to False.
cancelable
Whether clicking outside the outer circle dismisses the view.
cancelable is an BooleanProperty and defaults to False.
widget_position
Sets the position of the widget on the outer_circle. Available options are ‘left’, ‘right’, ‘top’, ‘bot-
tom’, ‘left_top’, ‘right_top’, ‘left_bottom’, ‘right_bottom’, ‘center’.
widget_position is an OptionProperty and defaults to ‘left’.
title_position
Sets the position of :attr`~title_text` on the outer circle. Only works if :attr`~widget_position` is set to
‘center’. In all other cases, it calculates the :attr`~title_position` itself. Must be set to other than ‘auto’
when :attr`~widget_position` is set to ‘center’.
Available options are ‘auto’, ‘left’, ‘right’, ‘top’, ‘bottom’, ‘left_top’, ‘right_top’, ‘left_bottom’,
‘right_bottom’, ‘center’.
title_position is an OptionProperty and defaults to ‘auto’.
stop_on_outer_touch
Whether clicking on outer circle stops the animation.
stop_on_outer_touch is an BooleanProperty and defaults to False.
stop_on_target_touch
Whether clicking on target circle should stop the animation.
stop_on_target_touch is an BooleanProperty and defaults to True.
state
State of MDTapTargetView.
state is an OptionProperty and defaults to ‘close’.
stop(self, *args)
Starts widget close animation.
start(self, *args)
Starts widget opening animation.
on_open(self, *args)
Called at the time of the start of the widget opening animation.
on_close(self, *args)
Called at the time of the start of the widget closed animation.
on_draw_shadow(self, instance, value)
on_description_text(self, instance, value)
2.4 Behaviors
2.4.1 Touch
Usage
KV = '''
Screen:
MyButton:
text: "PRESS ME"
pos_hint: {"center_x": .5, "center_y": .5}
'''
class MainApp(MDApp):
def build(self):
return Builder.load_string(KV)
MainApp().run()
API - kivymd.uix.behaviors.touch_behavior
class kivymd.uix.behaviors.touch_behavior.TouchBehavior(**kwargs)
duration_long_touch
Time for a long touch.
duration_long_touch is an NumericProperty and defaults to 0.4.
create_clock(self, widget, touch, *args)
delete_clock(self, widget, touch, *args)
on_long_touch(self, touch, *args)
Called when the widget is pressed for a long time.
on_double_tap(self, touch, *args)
Called by double clicking on the widget.
on_triple_tap(self, touch, *args)
Called by triple clicking on the widget.
2.4.2 Hover
To apply hover behavior, you must create a new class that is inherited from the widget to which you apply the behavior
and from the HoverBehavior class.
In KV file:
<HoverItem@MDBoxLayout+ThemableBehavior+HoverBehavior>
In python file:
After creating a class, you must define two methods for it: HoverBehavior.on_enter and HoverBehavior.
on_leave, which will be automatically called when the mouse cursor is over the widget and when the mouse cursor
goes beyond the widget.
KV = '''
Screen
MDBoxLayout:
id: box
pos_hint: {'center_x': .5, 'center_y': .5}
size_hint: .8, .8
md_bg_color: app.theme_cls.bg_darkest
'''
self.md_bg_color = (1, 1, 1, 1)
self.md_bg_color = self.theme_cls.bg_darkest
class Test(MDApp):
def build(self):
self.screen = Builder.load_string(KV)
for i in range(5):
self.screen.ids.box.add_widget(HoverItem())
return self.screen
Test().run()
API - kivymd.uix.behaviors.hover_behavior
class kivymd.uix.behaviors.hover_behavior.HoverBehavior(**kwargs)
Events
hovered
True, if the mouse cursor is within the borders of the widget.
hovered is an BooleanProperty and defaults to False.
border_point
Contains the last relevant point received by the Hoverable. This can be used in on_enter or on_leave
in order to know where was dispatched the event.
border_point is an ObjectProperty and defaults to None.
on_mouse_pos(self, *args)
on_enter(self )
Call when mouse enter the bbox of the widget.
on_leave(self )
Call when the mouse exit the widget.
2.4.3 Focus
To apply focus behavior, you must create a new class that is inherited from the widget to which you apply the behavior
and from the FocusBehavior class.
Usage
KV = '''
MDScreen:
md_bg_color: 1, 1, 1, 1
FocusWidget:
size_hint: .5, .3
pos_hint: {"center_x": .5, "center_y": .5}
md_bg_color: app.theme_cls.bg_light
MDLabel:
text: "Label"
theme_text_color: "Primary"
pos_hint: {"center_y": .5}
halign: "center"
'''
class Test(MDApp):
(continues on next page)
Test().run()
FocusWidget:
focus_color: 1, 0, 1, 1
unfocus_color: 0, 0, 1, 1
API - kivymd.uix.behaviors.focus_behavior
class kivymd.uix.behaviors.focus_behavior.FocusBehavior(**kwargs)
Events
focus_behavior
Using focus when hovering over a widget.
focus_behavior is a BooleanProperty and defaults to False.
focus_color
The color of the widget when the mouse enters the bbox of the widget.
focus_color is a ListProperty and defaults to [].
unfocus_color
The color of the widget when the mouse exits the bbox widget.
unfocus_color is a ListProperty and defaults to [].
on_enter(self )
Called when mouse enter the bbox of the widget.
on_leave(self )
Called when the mouse exit the widget.
2.4.4 Ripple
To create a widget with ircular ripple effect, you must create a new class that inherits from the
CircularRippleBehavior class.
For example, let’s create an image button with a circular ripple effect:
KV = '''
#:import images_path kivymd.images_path
Screen:
CircularRippleButton:
source: f"{images_path}/kivymd.png"
size_hint: None, None
size: "250dp", "250dp"
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Example(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
return Builder.load_string(KV)
Example().run()
To create a widget with rectangular ripple effect, you must create a new class that inherits from the
RectangularRippleBehavior class:
KV = '''
Screen:
class RectangularRippleButton(
RectangularRippleBehavior, ButtonBehavior, BackgroundColorBehavior
):
md_bg_color = [0, 0, 1, 1]
class Example(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
return Builder.load_string(KV)
Example().run()
API - kivymd.uix.behaviors.ripplebehavior
class kivymd.uix.behaviors.ripplebehavior.CommonRipple
Base class for ripple effect.
ripple_rad_default
Default value of the ripple effect radius.
ripple_duration_out
The duration of the disappearance of the wave effect.
2.4.5 Magic
To apply magic effects, you must create a new class that is inherited from the widget to which you apply the effect and
from the MagicBehavior class.
In KV file:
<MagicButton@MagicBehavior+MDRectangleFlatButton>
In python file:
class MagicButton(MagicBehavior, MDRectangleFlatButton):
pass
• MagicBehavior.wobble
• MagicBehavior.grow
• MagicBehavior.shake
• MagicBehavior.twist
• MagicBehavior.shrink
Example:
from kivymd.app import MDApp
from kivy.lang import Builder
KV = '''
#:import MagicBehavior kivymd.uix.behaviors.MagicBehavior
<MagicButton@MagicBehavior+MDRectangleFlatButton>
FloatLayout:
MagicButton:
text: "WOBBLE EFFECT"
on_release: self.wobble()
pos_hint: {"center_x": .5, "center_y": .3}
MagicButton:
text: "GROW EFFECT"
on_release: self.grow()
pos_hint: {"center_x": .5, "center_y": .4}
MagicButton:
text: "SHAKE EFFECT"
on_release: self.shake()
pos_hint: {"center_x": .5, "center_y": .5}
MagicButton:
text: "TWIST EFFECT"
on_release: self.twist()
pos_hint: {"center_x": .5, "center_y": .6}
MagicButton:
text: "SHRINK EFFECT"
on_release: self.shrink()
pos_hint: {"center_x": .5, "center_y": .7}
'''
(continues on next page)
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
Example().run()
API - kivymd.uix.behaviors.magic_behavior
class kivymd.uix.behaviors.magic_behavior.MagicBehavior
grow(self )
Grow effect animation.
shake(self )
Shake effect animation.
wobble(self )
Wobble effect animation.
twist(self )
Twist effect animation.
shrink(self )
Shrink effect animation.
Note: The following classes are intended for in-house use of the library.
API - kivymd.uix.behaviors.backgroundcolorbehavior
class kivymd.uix.behaviors.backgroundcolorbehavior.BackgroundColorBehavior(**kwargs)
Widget class. See module documentation for more information.
Events
on_touch_down: (touch, ) Fired when a new touch event occurs. touch is the touch object.
on_touch_move: (touch, ) Fired when an existing touch moves. touch is the touch object.
on_touch_up: (touch, ) Fired when an existing touch disappears. touch is the touch object.
on_kv_post: (base_widget, ) Fired after all the kv rules associated with the widget and all other
widgets that are in any of those rules have had all their kv rules applied. base_widget is
the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated
from Python, e.g. MyWidget()).
Changed in version 1.11.0.
Warning: Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable
automatic garbage collection for instances of that class. This is because the Widget class creates reference
cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the EventDispatcher.
Event properties can now be used when contructing a simple class without subclassing Widget.
Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to
properties or events, as in the Kv language.
r
The value of red in the rgba palette.
r is an BoundedNumericProperty and defaults to 1.0.
g
The value of green in the rgba palette.
g is an BoundedNumericProperty and defaults to 1.0.
b
The value of blue in the rgba palette.
b is an BoundedNumericProperty and defaults to 1.0.
a
The value of alpha channel in the rgba palette.
a is an BoundedNumericProperty and defaults to 0.0.
radius
Canvas radius.
Widget:
canvas:
Color:
rgba: 0, 1, 1, 1
Rectangle:
size: self.size
pos: self.pos
similar to code:
<MyWidget@BackgroundColorBehavior>
md_bg_color: 0, 1, 1, 1
class kivymd.uix.behaviors.backgroundcolorbehavior.SpecificBackgroundColorBehavior(**kwargs)
Widget class. See module documentation for more information.
Events
on_touch_down: (touch, ) Fired when a new touch event occurs. touch is the touch object.
on_touch_move: (touch, ) Fired when an existing touch moves. touch is the touch object.
on_touch_up: (touch, ) Fired when an existing touch disappears. touch is the touch object.
on_kv_post: (base_widget, ) Fired after all the kv rules associated with the widget and all other
widgets that are in any of those rules have had all their kv rules applied. base_widget is
the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated
from Python, e.g. MyWidget()).
Changed in version 1.11.0.
Warning: Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable
automatic garbage collection for instances of that class. This is because the Widget class creates reference
cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the EventDispatcher.
Event properties can now be used when contructing a simple class without subclassing Widget.
Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to
properties or events, as in the Kv language.
background_palette
See kivymd.color_definitions.palette.
background_palette is an OptionProperty and defaults to ‘Primary’.
background_hue
See kivymd.color_definitions.hue.
background_hue is an OptionProperty and defaults to ‘500’.
specific_text_color
specific_text_color is an ListProperty and defaults to [0, 0, 0, 0.87].
specific_secondary_text_color
specific_secondary_text_color`is an :class:`~kivy.properties.
ListProperty and defaults to [0, 0, 0, 0.87].
2.4.7 Elevation
To create a widget with rectangular or circular elevation effect, you must create a new class that inherits from the
RectangularElevationBehavior or CircularElevationBehavior class.
For example, let’s create an button with a rectangular elevation effect:
KV = '''
<RectangularElevationButton>:
size_hint: None, None
size: "250dp", "50dp"
Screen:
class RectangularElevationButton(
RectangularRippleBehavior,
RectangularElevationBehavior,
ButtonBehavior,
BackgroundColorBehavior,
):
md_bg_color = [0, 0, 1, 1]
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
Example().run()
KV = '''
#:import images_path kivymd.images_path
(continues on next page)
<CircularElevationButton>:
size_hint: None, None
size: "100dp", "100dp"
source: f"{images_path}/kivymd.png"
Screen:
class CircularElevationButton(
CircularRippleBehavior,
CircularElevationBehavior,
ButtonBehavior,
Image,
):
md_bg_color = [0, 0, 1, 1]
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
Example().run()
API - kivymd.uix.behaviors.elevation
class kivymd.uix.behaviors.elevation.CommonElevationBehavior(**kwargs)
Common base class for rectangular and circular elevation behavior.
elevation
Elevation value.
elevation is an NumericProperty and defaults to 1.
class kivymd.uix.behaviors.elevation.RectangularElevationBehavior(**kwargs)
Base class for rectangular elevation behavior. Controls the size and position of the shadow.
class kivymd.uix.behaviors.elevation.CircularElevationBehavior(**kwargs)
Base class for circular elevation behavior. Controls the size and position of the shadow.
2.4.8 ToggleButton
This behavior must always be inherited after the button’s Widget class since it works with the inherited properties of
the button class.
example:
KV = '''
Screen:
MDBoxLayout:
adaptive_size: True
pos_hint: {"center_x": .5, "center_y": .5}
MyToggleButton:
text: "Show ads"
group: "x"
MyToggleButton:
text: "Do not show ads"
group: "x"
MyToggleButton:
text: "Does not matter"
group: "x"
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
You can inherit the MyToggleButton class only from the following classes
• MDRaisedButton
• MDFlatButton
• MDRectangleFlatButton
• MDRectangleFlatIconButton
• MDRoundFlatButton
• MDRoundFlatIconButton
• MDFillRoundFlatButton
• MDFillRoundFlatIconButton
API - kivymd.uix.behaviors.toggle_behavior
class kivymd.uix.behaviors.toggle_behavior.MDToggleButton(**kwargs)
This mixin class provides togglebutton behavior. Please see the togglebutton behaviors
module documentation for more information.
New in version 1.8.0.
background_normal
Color of the button in rgba format for the ‘normal’ state.
background_normal is a ListProperty and is defaults to [].
background_down
Color of the button in rgba format for the ‘down’ state.
background_down is a ListProperty and is defaults to [].
font_color_normal
Color of the font’s button in rgba format for the ‘normal’ state.
font_color_normal is a ListProperty and is defaults to [].
font_color_down
Color of the font’s button in rgba format for the ‘down’ state.
font_color_down is a ListProperty and is defaults to [1, 1, 1, 1].
2.5.1 Unreleased
• Added features to Snackbar class: use padding, set custom button color, elevation
• Add MDToggleButton class
• Change to Material Design Baseline dark theme spec
• Fix ReferenceError: weakly-referenced object no longer exists when start demo application
• Changed the default value for the theme_text_color parameter in the BaseButton class (to the value “Primary”)
• Fix setting of the text_color_normal and text_color_active parameters - earlier their values did not affect any-
thing
• Fixed the length of the right edge of the border in relation to the hint text when the MDTextField is in the
rectangle mode
• Add get_tab_list method to MDTabs class
• Add hover behavior when using MDDropdownMenu class
• Added the feature to use the FitImage component to download images from the network
• The elevation value for RectangularElevationBehavior and CircularElevationBehavior classes after pressing
was always set to 2 - fixed
• Methods that implement the ripple effect have always been called twice - fixed
• The SmartTile class now uses the FitImage class to display images instead of the Image class
• Removed dependency on PIL library
• Add hint_bg_color, hint_text_color, hint_radius attributes to MDSlider class
• Delete progressloader.py
• Delete context_menu.py
• Added the feature to control the properties of menu items during creation in MDDropdownMenu class
• Added the feature to change the number of buttons after creating the MDFloatingActionButtonSpeedDial object
• Added the feature to set the font_name property for the MDTabsLabel class
• Add MDCarousel class
• Delete kivymd/uix/useranimationcard.py
2.5.2 0.104.1
• Added a shadow, increased speed of opening, added the feature to control the position of the MDDropdownMenu
class
• The MDDropDownItem class is now a regular element, such as a button
• Added the ability to use the texture of the icon on the right in any MDTextField classes
• Added the feature to use ripple and focus behavior in MDCard class
• MDDialogs class redesigned to meet material design requirements
• Added MDDataTable class
2.5.3 0.104.0
2.5.4 0.103.0
2.5.5 0.102.1
2.5.6 0.102.0
2.5.7 0.101.8
2.5.8 0.101.7
• Fixed colors and position of the buttons in the Buttons demo screen ([Kitchen Sink demo](https://github.com/
kivymd/KivyMD/tree/master/demos/kitchen_sink)).
• Displaying percent of loading kv-files ([Kitchen Sink demo](https://github.com/kivymd/KivyMD/tree/master/
demos/kitchen_sink)).
2.5.9 0.101.6
2.5.10 0.101.5
• Added feature to see source code of current example ([Kitchen Sink demo](https://github.com/kivymd/KivyMD/
tree/master/demos/kitchen_sink)).
• Added names of authors of this fork ([Kitchen Sink demo](https://github.com/kivymd/KivyMD/tree/master/
demos/kitchen_sink)).
• Bug fixes and other minor improvements.
2.5.11 0.101.4
2.5.12 0.101.3
2.5.13 0.101.2
2.5.14 0.101.1
2.5.15 0.101.0
2.5.16 0.100.2
• [Black](https://github.com/psf/black) formatting.
2.5.17 0.100.1
2.5.18 0.100.0
2.5.19 0.99.99.01
• Fixed MDNavigationDrawer.use_logo.
2.5.20 0.99.99
2.5.21 0.99.98
2.5.22 0.99.97
2.5.23 0.99.96
2.5.24 0.99.95
2.5.25 0.99.94
2.5.26 0.99.93
2.5.27 0.99.92
2.6 About
2.6.1 License
Refer to LICENSE.
MIT License
Copyright (c) 2015 Andrés Rodríguez and other contributors - KivyMD library up to
˓→version 0.1.2
Copyright (c) 2020 KivyMD Team and other contributors - KivyMD library version 0.1.3
˓→and higher
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
(continues on next page)
2.7 KivyMD
Is a collection of Material Design compliant widgets for use with, Kivy cross-platform graphical framework a frame-
work for cross-platform, touch-enabled graphical applications. The project’s goal is to approximate Google’s Material
Design spec as close as possible without sacrificing ease of use or application performance.
This library is a fork of the KivyMD project the author of which stopped supporting this project three years ago. We
found the strength and brought this project to a new level. Currently we’re in beta status, so things are changing all
the time and we cannot promise any kind of API stability. However it is safe to vendor now and make use of what’s
currently available.
Join the project! Just fork the project, branch out and submit a pull request when your patch is ready. If any changes
are necessary, we’ll guide you through the steps that need to be done via PR comments or access to your for may
be requested to outright submit them. If you wish to become a project developer (permission to create branches on
the project without forking for easier collaboration), have at least one PR approved and ask for it. If you contribute
regularly to the project the role may be offered to you without asking too.
kivymd.release = False
kivymd.path
Path to KivyMD package directory.
kivymd.fonts_path
Path to fonts directory.
kivymd.images_path
Path to images directory.
2.7.2 Submodules
API - kivymd.factory_registers
kivymd.factory_registers.r
Material Resources
API - kivymd.material_resources
kivymd.material_resources.dp
kivymd.material_resources.DEVICE_IOS
kivymd.material_resources.DEVICE_TYPE = desktop
kivymd.material_resources.MAX_NAV_DRAWER_WIDTH
kivymd.material_resources.TOUCH_TARGET_HEIGHT
Two implementations. The first is based on color brightness obtained from- https://www.w3.org/TR/AERT#
color-contrast The second is based on relative luminance calculation for sRGB obtained from- https://www.w3.
org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef and contrast ratio calculation obtained from- https:
//www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef
Preliminary testing suggests color brightness more closely matches the Material Design spec suggested text colors,
but the alternative implementation is both newer and the current ‘correct’ recommendation, so is included here as an
option.
API - kivymd.theming_dynamic_text
kivymd.theming_dynamic_text.get_contrast_text_color(color,
use_color_brightness=True)
kivymd.theming_dynamic_text.color
An Effect to be used with ScrollView to prevent scrolling beyond the bounds, but politely.
A ScrollView constructed with StiffScrollEffect, eg. ScrollView(effect_cls=StiffScrollEffect), will get harder to scroll
as you get nearer to its edges. You can scroll all the way to the edge if you want to, but it will take more finger-
movement than usual.
Unlike DampedScrollEffect, it is impossible to overscroll with StiffScrollEffect. That means you cannot push the
contents of the ScrollView far enough to see what’s beneath them. This is appropriate if the ScrollView contains, eg.,
a background image, like a desktop wallpaper. Overscrolling may give the impression that there is some reason to
overscroll, even if just to take a peek beneath, and that impression may be misleading.
StiffScrollEffect was written by Zachary Spector. His other stuff is at: https://github.com/LogicalDash/ He can be
reached, and possibly hired, at: zacharyspector@gmail.com
API - kivymd.stiffscroll
class kivymd.stiffscroll.StiffScrollEffect(**kwargs)
Kinetic effect class. See module documentation for more information.
drag_threshold
Minimum distance to travel before the movement is considered as a drag.
drag_threshold is an NumericProperty and defaults to ’20sp’.
min
Minimum boundary to stop the scrolling at.
min is an NumericProperty and defaults to 0.
max
Maximum boundary to stop the scrolling at.
max is an NumericProperty and defaults to 0.
max_friction
How hard should it be to scroll, at the worst?
max_friction is an NumericProperty and defaults to 1.
body
Proportion of the range in which you can scroll unimpeded.
body is an NumericProperty and defaults to 0.7.
scroll
Computed value for scrolling
scroll is an NumericProperty and defaults to 0.0.
transition_min
The AnimationTransition function to use when adjusting the friction near the minimum end of the effect.
transition_min is an ObjectProperty and defaults to kivy.animation.
AnimationTransition.
transition_max
The AnimationTransition function to use when adjusting the friction near the maximum end of the effect.
transition_max is an ObjectProperty and defaults to kivy.animation.
AnimationTransition.
target_widget
The widget to apply the effect to.
target_widget is an ObjectProperty and defaults to None.
displacement
The absolute distance moved in either direction.
displacement is an NumericProperty and defaults to 0.
update_velocity(self, dt)
Before actually updating my velocity, meddle with self.friction to make it appropriate to where
I’m at, currently.
on_value(self, *args)
Prevent moving beyond my bounds, and update self.scroll
start(self, val, t=None)
Start movement with self.friction = self.base_friction
update(self, val, t=None)
Reduce the impact of whatever change has been made to me, in proportion with my current friction.
stop(self, val, t=None)
Work out whether I’ve been flung.
kivymd.toast
API - kivymd.toast
Submodules
API - kivymd.toast.androidtoast
Submodules
AndroidToast
KV = '''
BoxLayout:
orientation:'vertical'
MDToolbar:
(continues on next page)
FloatLayout:
MDRaisedButton:
text: 'TEST KIVY TOAST'
on_release: app.show_toast()
pos_hint: {'center_x': .5, 'center_y': .5}
'''
class Test(MDApp):
def show_toast(self):
'''Displays a toast on the screen.'''
def build(self):
return Builder.load_string(KV)
Test().run()
API - kivymd.toast.androidtoast.androidtoast
kivymd.toast.androidtoast.androidtoast.toast(text, length_long=False)
Displays a toast.
Length_long The amount of time (in seconds) that the toast is visible on the screen.
kivymd.toast.kivytoast
API - kivymd.toast.kivytoast
Submodules
KivyToast
KV = '''
BoxLayout:
orientation:'vertical'
(continues on next page)
MDToolbar:
id: toolbar
title: 'Test Toast'
md_bg_color: app.theme_cls.primary_color
left_action_items: [['menu', lambda x: '']]
FloatLayout:
MDRaisedButton:
text: 'TEST KIVY TOAST'
on_release: app.show_toast()
pos_hint: {'center_x': .5, 'center_y': .5}
'''
class Test(MDApp):
def show_toast(self):
'''Displays a toast on the screen.'''
def build(self):
return Builder.load_string(KV)
Test().run()
API - kivymd.toast.kivytoast.kivytoast
class kivymd.toast.kivytoast.kivytoast.Toast(**kwargs)
ModalView class. See module documentation for more information.
Events
on_pre_open: Fired before the ModalView is opened. When this event is fired ModalView is
not yet added to window.
on_open: Fired when the ModalView is opened.
on_pre_dismiss: Fired before the ModalView is closed.
on_dismiss: Fired when the ModalView is closed. If the callback returns True, the dismiss will
be canceled.
Changed in version 1.11.0: Added events on_pre_open and on_pre_dismiss.
duration
The amount of time (in seconds) that the toast is visible on the screen.
duration is an NumericProperty and defaults to 2.5.
label_check_texture_size(self, instance, texture_size)
toast(self, text_toast)
on_open(self )
fade_in(self )
fade_out(self, interval)
on_touch_down(self, touch)
Receive a touch down event.
Parameters
touch: MotionEvent class Touch received. The touch is in parent coordinates. See
relativelayout for a discussion on coordinate systems.
Returns bool If True, the dispatching of the touch event will stop. If False, the event will
continue to be dispatched to the rest of the widget tree.
kivymd.toast.kivytoast.kivytoast.toast(text: str, duration=2.5)
Displays a toast.
Duration The amount of time (in seconds) that the toast is visible on the screen.
kivymd.tools
API - kivymd.tools
Submodules
kivymd.tools.packaging
API - kivymd.tools.packaging
Submodules
PyInstaller hooks
import sys
import os
path = os.path.abspath(".")
a = Analysis(
["main.py"],
pathex=[path],
hookspath=[kivymd_hooks_path],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=None,
(continues on next page)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
debug=False,
strip=False,
upx=True,
name="app_name",
console=True,
)
API - kivymd.tools.packaging.pyinstaller
kivymd.tools.packaging.pyinstaller.hooks_path
Path to hook directory to use with PyInstaller. See kivymd.tools.packaging.pyinstaller for more
information.
kivymd.tools.packaging.pyinstaller.datas = [None, None]
kivymd.tools.packaging.pyinstaller.hiddenimports = ['PIL']
Submodules
kivymd.tools.packaging.pyinstaller.hook-kivymd
API - kivymd.tools.packaging.pyinstaller.hook-kivymd
kivymd.tools.release
API - kivymd.tools.release
Submodules
kivymd.tools.release.argument_parser
API - kivymd.tools.release.argument_parser
class kivymd.tools.release.argument_parser.ArgumentParserWithHelp(prog=None,
us-
age=None,
descrip-
tion=None,
epi-
log=None,
parents=[],
format-
ter_class=HelpFormatter,
prefix_chars='-
', from-
file_prefix_chars=None,
argu-
ment_default=None,
con-
flict_handler='error',
add_help=True,
al-
low_abbrev=True)
Object for parsing command line strings into Python objects.
Keyword Arguments:
• prog – The name of the program (default: sys.argv[0])
• usage – A usage message (default: auto-generated from arguments)
• description – A description of what the program does
• epilog – Text following the argument descriptions
• parents – Parsers whose arguments should be copied into this one
• formatter_class – HelpFormatter class for printing help messages
• prefix_chars – Characters that prefix optional arguments
• fromfile_prefix_chars – Characters that prefix files containing additional arguments
• argument_default – The default value for all arguments
• conflict_handler – String indicating how to handle conflicts
• add_help – Add a -h/-help option
• allow_abbrev – Allow long options to be abbreviated unambiguously
parse_args(self, args=None, namespace=None)
error(self, message)
error(message: string)
Prints a usage message incorporating the message to stderr and exits.
If you override this in a subclass, it should not return – it should either exit or raise an exception.
format_help(self )
kivymd.tools.release.git_commands
API - kivymd.tools.release.git_commands
API - kivymd.tools.release.make_release
kivymd.tools.release.make_release.run_pre_commit()
Run pre-commit.
kivymd.tools.release.make_release.replace_in_file(pattern, repl, file)
Replace one pattern match to repl in file file.
kivymd.tools.release.make_release.update_init_py(version, is_release, test: bool =
False)
Change version in kivymd/__init__.py.
API - kivymd.tools.release.update_icons
kivymd.tools.release.update_icons.kivymd_path
kivymd.tools.release.update_icons.font_path
kivymd.tools.release.update_icons.icon_definitions_path
kivymd.tools.release.update_icons.font_version = master
kivymd.tools.release.update_icons.url
kivymd.tools.release.update_icons.temp_path
kivymd.tools.release.update_icons.temp_repo_path
kivymd.tools.release.update_icons.temp_font_path
kivymd.tools.release.update_icons.temp_preview_path
kivymd.tools.release.update_icons.re_icons_json
kivymd.tools.release.update_icons.re_additional_icons
kivymd.tools.release.update_icons.re_version
kivymd.tools.release.update_icons.re_quote_keys
kivymd.tools.release.update_icons.re_icon_definitions
kivymd.tools.release.update_icons.re_version_in_file
kivymd.tools.release.update_icons.download_file(url, path)
kivymd.tools.release.update_icons.unzip_archive(archive_path, dir_path)
kivymd.tools.release.update_icons.get_icons_list()
kivymd.tools.release.update_icons.make_icon_definitions(icons)
kivymd.tools.release.update_icons.export_icon_definitions(icon_definitions, ver-
sion)
kivymd.tools.release.update_icons.update_icons(make_commit: bool = False)
kivymd.tools.release.update_icons.main()
kivymd.uix
API - kivymd.uix
class kivymd.uix.MDAdaptiveWidget(**kwargs)
Widget class. See module documentation for more information.
Events
on_touch_down: (touch, ) Fired when a new touch event occurs. touch is the touch object.
on_touch_move: (touch, ) Fired when an existing touch moves. touch is the touch object.
on_touch_up: (touch, ) Fired when an existing touch disappears. touch is the touch object.
on_kv_post: (base_widget, ) Fired after all the kv rules associated with the widget and all other
widgets that are in any of those rules have had all their kv rules applied. base_widget is
the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated
from Python, e.g. MyWidget()).
Changed in version 1.11.0.
Warning: Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable
automatic garbage collection for instances of that class. This is because the Widget class creates reference
cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the EventDispatcher.
Event properties can now be used when contructing a simple class without subclassing Widget.
Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to
properties or events, as in the Kv language.
adaptive_height
If True, the following properties will be applied to the widget:
size_hint_y: None
height: self.minimum_height
size_hint_x: None
width: self.minimum_width
Submodules
kivymd.uix.carousel
API - kivymd.uix.carousel
class kivymd.uix.carousel.MDCarousel(**kwargs)
Carousel class. See module documentation for more information.
on_slide_progress(self, *args)
on_slide_complete(self, *args)
Behaviors
API - kivymd.uix.behaviors
Submodules
kivymd.utils
API - kivymd.utils
Submodules
asynckivy
API - kivymd.utils.asynckivy
kivymd.utils.asynckivy.start(coro)
kivymd.utils.asynckivy.sleep(duration)
class kivymd.utils.asynckivy.event(ed, name)
bind(self, step_coro)
callback(self, *args, **kwargs)
Crop Image
API - kivymd.utils.cropimage
Fit Image
Feature to automatically crop a Kivy image to fit your layout Write by Benedikt Zwölfer
Referene - https://gist.github.com/benni12er/95a45eb168fc33a4fcd2d545af692dad
Example:
BoxLayout:
size_hint_y: None
height: "200dp"
orientation: 'vertical'
FitImage:
size_hint_y: 3
source: 'images/img1.jpg'
FitImage:
size_hint_y: 1
source: 'images/img2.jpg'
Builder.load_string(
'''
<Card>:
elevation: 10
(continues on next page)
FitImage:
id: bg_image
source: "images/bg.png"
size_hint_y: .35
pos_hint: {"top": 1}
radius: [36, 36, 0, 0, ]
''')
class Card(MDCard):
pass
class Example(MDApp):
def build(self):
modal = ModalView(
size_hint=(0.4, 0.8),
background=f"{images_path}/transparent.png",
overlay_color=(0, 0, 0, 0),
)
modal.add_widget(Card())
modal.open()
Example().run()
API - kivymd.utils.fitimage
class kivymd.utils.fitimage.FitImage(**kwargs)
Box layout class. See module documentation for more information.
source
container
radius
Monitor module
The Monitor module is a toolbar that shows the activity of your current application :
• FPS
API - kivymd.utils.fpsmonitor
class kivymd.utils.fpsmonitor.FpsMonitor(**kwargs)
Label class, see module documentation for more information.
Events
on_ref_press Fired when the user clicks on a word referenced with a [ref] tag in a text
markup.
updated_interval
FPS refresh rate.
start(self )
update_fps(self, *args)
HotReloadViewer
HotReloadViewer, for KV-Viewer, is a simple tool allowing you to dynamically display a KV file, taking its
changes into account (thanks to watchdog). The idea is to facilitate design using the KV language.
Usage
KV = '''
#:import KivyLexer kivy.extras.highlight.KivyLexer
#:import HotReloadViewer kivymd.utils.hot_reload_viewer.HotReloadViewer
BoxLayout:
CodeInput:
lexer: KivyLexer()
style_name: "native"
on_text: app.update_kv_file(self.text)
size_hint_x: .7
HotReloadViewer:
size_hint_x: .3
path: app.path_to_kv_file
errors: True
(continues on next page)
class Example(MDApp):
path_to_kv_file = "kv_file.kv"
def build(self):
self.theme_cls.theme_style = "Dark"
return Builder.load_string(KV)
Example().run()
This will display the test.kv and automatically update the display when the file changes.
This scripts uses watchdog to listen for file changes. To install watchdog.
API - kivymd.utils.hot_reload_viewer
class kivymd.utils.hot_reload_viewer.HotReloadErrorText(**kwargs)
ScrollView class. See module documentation for more information.
Events
on_scroll_start Generic event fired when scrolling starts from touch.
on_scroll_move Generic event fired when scrolling move from touch.
on_scroll_stop Generic event fired when scrolling stops from touch.
Changed in version 1.9.0: on_scroll_start, on_scroll_move and on_scroll_stop events are now dispatched when
scrolling to handle nested ScrollViews.
Changed in version 1.7.0: auto_scroll, scroll_friction, scroll_moves, scroll_stoptime’ has been deprecated, use
:attr:`effect_cls instead.
text
Text errors.
text is an StringProperty and defaults to ‘’.
errors_text_color
Error text color.
errors_text_color is an ListProperty and defaults to [].
class kivymd.utils.hot_reload_viewer.HotReloadHandler(callback, target, **kwargs)
on_any_event(self, event)
class kivymd.utils.hot_reload_viewer.HotReloadViewer(**kwargs)
Events
on_error Called when an error occurs in the KV-file that the user is editing.
path
Path to KV file.
path is an StringProperty and defaults to ‘’.
errors
Show errors while editing KV-file.
errors is an BooleanProperty and defaults to False.
errors_background_color
Error background color.
errors_background_color is an ListProperty and defaults to [].
errors_text_color
Error text color.
errors_text_color is an ListProperty and defaults to [].
update(self, *args)
Updates and displays the KV-file that the user edits.
show_error(self, error)
Displays text with a current error.
on_error(self, *args)
Called when an error occurs in the KV-file that the user is editing.
on_errors_text_color(self, instance, value)
on_path(self, instance, value)
kivymd.vendor
API - kivymd.vendor
Submodules
CircularLayout
size_hint
size_hint_x is used as an angle-quota hint (widget with higher size_hint_x will be farther from each other, and vice
versa), while size_hint_y is used as a widget size hint (widgets with a higher size hint will be bigger).size_hint_x
cannot be None.
Widgets are all squares, unless you set size_hint_y to None (in that case you’ll be able to specify your own size), and
their size is the difference between the outer and the inner circle’s radii. To make the widgets bigger you can just
decrease inner_radius_hint.
API - kivymd.vendor.circleLayout
class kivymd.vendor.circleLayout.CircularLayout(**kwargs)
Circular layout class. See module documentation for more information.
padding
Padding between the layout box and it’s children: [padding_left, padding_top, padding_right,
padding_bottom].
padding also accepts a two argument form [padding_horizontal, padding_vertical] and a one argument
form [padding].
padding is a VariableListProperty and defaults to [0, 0, 0, 0].
start_angle
Angle (in degrees) at which the first widget will be placed. Start counting angles from the X axis, going
counterclockwise.
start_angle is a NumericProperty and defaults to 0 (start from the right).
circle_quota
Size (in degrees) of the part of the circumference that will actually be used to place widgets.
circle_quota is a BoundedNumericProperty and defaults to 360 (all the circumference).
direction
Direction of widgets in the circle.
direction is an OptionProperty and defaults to ‘ccw’. Can be ‘ccw’ (counterclockwise) or ‘cw’
(clockwise).
outer_radius_hint
Sets the size of the outer circle. A number greater than 1 will make the widgets larger than the actual
widget, a number smaller than 1 will leave a gap.
outer_radius_hint is a NumericProperty and defaults to 1.
inner_radius_hint
Sets the size of the inner circle. A number greater than outer_radius_hint will cause glitches. The
closest it is to outer_radius_hint, the smallest will be the widget in the layout.
outer_radius_hint is a NumericProperty and defaults to 1.
radius_hint
Combined outer_radius_hint and inner_radius_hint in a list for convenience. See their
documentation for more details.
radius_hint is a ReferenceListProperty.
delta_radii
do_layout(self, *largs)
This function is called when a layout is called by a trigger. If you are writing a new Layout subclass, don’t
call this function directly but use _trigger_layout() instead.
The function is by default called before the next frame, therefore the layout isn’t updated immediately.
Anything depending on the positions of e.g. children should be scheduled for the next frame.
New in version 1.0.8.
Simple usage
class Example(MDApp):
def build(self):
box = MDScreen(md_bg_color=self.theme_cls.bg_darkest)
box.add_widget(CircularTimePicker())
return box
Example().run()
in Kv language:
<TimeChooserPopup@Popup>:
MDBoxLayout:
orientation: "vertical"
CircularTimePicker:
Button:
text: "Dismiss"
size_hint_y: None
height: "40dp"
on_release: root.dismiss()
API - kivymd.vendor.circularTimePicker
number_format_string
String that will be formatted with the selected number as the first argument. Can be anything supported by
str.format() (es. “{:02d}”).
number_format_string is a StringProperty and defaults to “{}”.
scale
Canvas scale factor. Used in CircularTimePicker transitions.
scale is a NumericProperty and defaults to 1.
items
shown_items
dot_is_none(self, *args)
on_touch_down(self, touch)
Receive a touch down event.
Parameters
touch: MotionEvent class Touch received. The touch is in parent coordinates. See
relativelayout for a discussion on coordinate systems.
Returns bool If True, the dispatching of the touch event will stop. If False, the event will
continue to be dispatched to the rest of the widget tree.
on_touch_move(self, touch)
Receive a touch move event. The touch is in parent coordinates.
See on_touch_down() for more information.
on_touch_up(self, touch)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
on_selected(self, *a)
pos_for_number(self, n)
Returns the center x, y coordinates for a given number.
number_at_pos(self, x, y)
Returns the number at a given x, y position. The number is found using the widget’s center as a starting
point for angle calculations.
Not thoroughly tested, may yield wrong results.
class kivymd.vendor.circularTimePicker.CircularMinutePicker(**kw)
CircularNumberPicker implementation for minutes.
class kivymd.vendor.circularTimePicker.CircularHourPicker(**kw)
CircularNumberPicker implementation for hours.
class kivymd.vendor.circularTimePicker.CircularTimePicker(**kw)
Widget that makes use of CircularHourPicker and CircularMinutePicker to create a user-friendly,
animated time picker like the one seen on Android.
See module documentation for more details.
primary_dark
hours
The hours, in military format (0-23).
is_not_animating(self, *args)
on_touch_down(self, touch)
Receive a touch down event.
Parameters
touch: MotionEvent class Touch received. The touch is in parent coordinates. See
relativelayout for a discussion on coordinate systems.
Returns bool If True, the dispatching of the touch event will stop. If False, the event will
continue to be dispatched to the rest of the widget tree.
on_touch_up(self, touch)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
class kivymd.vendor.circularTimePicker.Example(**kwargs)
Application class, see module documentation for more information.
Events
on_start: Fired when the application is being started (before the runTouchApp() call.
on_stop: Fired when the application stops.
on_pause: Fired when the application is paused by the OS.
on_resume: Fired when the application is resumed from pause by the OS. Beware: you have
no guarantee that this event will be fired after the on_pause event has been called.
Changed in version 1.7.0: Parameter kv_file added.
Changed in version 1.8.0: Parameters kv_file and kv_directory are now properties of App.
build(self )
Initializes the application; it will be called only once. If this method returns a widget (tree), it will be used
as the root widget and added to the window.
Returns None or a root Widget instance if no self.root exists.
THREE
• genindex
• modindex
• search
277
KivyMD, Release 0.104.2.dev0
k kivymd.uix.bottomnavigation, 26
kivymd, 251 kivymd.uix.bottomsheet, 59
kivymd.app, 16 kivymd.uix.boxlayout, 135
kivymd.color_definitions, 18 kivymd.uix.button, 121
kivymd.factory_registers, 252 kivymd.uix.card, 179
kivymd.font_definitions, 23 kivymd.uix.carousel, 263
kivymd.icon_definitions, 21 kivymd.uix.chip, 192
kivymd.material_resources, 252 kivymd.uix.datatables, 209
kivymd.stiffscroll, 252 kivymd.uix.dialog, 72
kivymd.theming, 6 kivymd.uix.dropdownitem, 52
kivymd.theming_dynamic_text, 252 kivymd.uix.expansionpanel, 94
kivymd.toast, 254 kivymd.uix.filemanager, 195
kivymd.toast.androidtoast, 254 kivymd.uix.floatlayout, 119
kivymd.toast.androidtoast.androidtoast, kivymd.uix.gridlayout, 120
254 kivymd.uix.imagelist, 141
kivymd.toast.kivytoast, 255 kivymd.uix.label, 175
kivymd.toast.kivytoast.kivytoast, 255 kivymd.uix.list, 162
kivymd.tools, 257 kivymd.uix.menu, 105
kivymd.tools.packaging, 257 kivymd.uix.navigationdrawer, 86
kivymd.tools.packaging.pyinstaller, 257 kivymd.uix.picker, 53
kivymd.uix.progressbar, 67
kivymd.tools.packaging.pyinstaller.hook-kivymd,
258 kivymd.uix.refreshlayout, 145
kivymd.tools.release, 258 kivymd.uix.relativelayout, 206
kivymd.tools.release.argument_parser, kivymd.uix.screen, 208
258 kivymd.uix.selectioncontrol, 137
kivymd.tools.release.git_commands, 260 kivymd.uix.slider, 159
kivymd.tools.release.make_release, 260 kivymd.uix.snackbar, 32
kivymd.tools.release.update_icons, 261 kivymd.uix.spinner, 24
kivymd.uix, 262 kivymd.uix.stacklayout, 207
kivymd.uix.backdrop, 202 kivymd.uix.tab, 41
kivymd.uix.banner, 37 kivymd.uix.taptargetview, 215
kivymd.uix.behaviors, 263 kivymd.uix.textfield, 147
kivymd.uix.toolbar, 98
kivymd.uix.behaviors.backgroundcolorbehavior,
236 kivymd.uix.tooltip, 199
kivymd.uix.behaviors.elevation, 238 kivymd.uix.useranimationcard, 83
kivymd.uix.behaviors.focus_behavior, 230 kivymd.utils, 263
kivymd.uix.behaviors.hover_behavior, 228 kivymd.utils.asynckivy, 263
kivymd.uix.behaviors.magic_behavior, 234 kivymd.utils.cropimage, 264
kivymd.uix.behaviors.ripplebehavior, 232 kivymd.utils.fitimage, 264
kivymd.uix.behaviors.toggle_behavior, kivymd.utils.fpsmonitor, 267
241 kivymd.utils.hot_reload_viewer, 267
kivymd.uix.behaviors.touch_behavior, 227 kivymd.vendor, 269
279
KivyMD, Release 0.104.2.dev0
kivymd.vendor.circleLayout, 269
kivymd.vendor.circularTimePicker, 271
A add_item() (kivymd.uix.bottomsheet.MDListBottomSheet
method), 66
a (kivymd.uix.behaviors.backgroundcolorbehavior.BackgroundColorBehavior
attribute), 237 add_scrim() (kivymd.uix.navigationdrawer.NavigationLayout
accent_color (kivymd.theming.ThemeManager at- method), 91
tribute), 10 add_widget() (kivymd.uix.backdrop.MDBackdrop
accent_dark (kivymd.theming.ThemeManager at- method), 205
tribute), 10 add_widget() (kivymd.uix.bottomnavigation.MDBottomNavigation
accent_dark_hue (kivymd.theming.ThemeManager method), 31
attribute), 10 add_widget() (kivymd.uix.bottomsheet.MDBottomSheet
accent_hue (kivymd.theming.ThemeManager at- method), 65
tribute), 10 add_widget() (kivymd.uix.card.MDCardSwipe
accent_light (kivymd.theming.ThemeManager at- method), 190
tribute), 10 add_widget() (kivymd.uix.chip.MDChooseChip
accent_light_hue (kivymd.theming.ThemeManager method), 195
attribute), 10 add_widget() (kivymd.uix.expansionpanel.MDExpansionPanel
accent_palette (kivymd.theming.ThemeManager method), 97
attribute), 10 add_widget() (kivymd.uix.list.ContainerSupport
active (kivymd.uix.selectioncontrol.MDCheckbox at- method), 173
tribute), 140 add_widget() (kivymd.uix.list.MDList method), 171
active (kivymd.uix.selectioncontrol.MDSwitch at- add_widget() (kivymd.uix.navigationdrawer.NavigationLayout
tribute), 141 method), 91
active (kivymd.uix.slider.MDSlider attribute), 161 add_widget() (kivymd.uix.tab.MDTabs method), 50
active (kivymd.uix.spinner.MDSpinner attribute), 26 add_widget() (kivymd.uix.toolbar.MDBottomAppBar
active_line (kivymd.uix.textfield.MDTextField at- method), 104
tribute), 157 adjust_tooltip_position()
adaptive_height (kivymd.uix.MDAdaptiveWidget (kivymd.uix.tooltip.MDTooltip method), 201
attribute), 262 allow_stretch (kivymd.uix.tab.MDTabs attribute),
adaptive_size (kivymd.uix.MDAdaptiveWidget at- 50
tribute), 262 ampm_format (kivymd.vendor.circularTimePicker.CircularTimePicker
adaptive_width (kivymd.uix.MDAdaptiveWidget at- attribute), 274
tribute), 262 ampm_text (kivymd.vendor.circularTimePicker.CircularTimePicker
add_actions_buttons() attribute), 274
(kivymd.uix.banner.MDBanner method), anchor (kivymd.uix.button.MDFloatingActionButtonSpeedDial
40 attribute), 133
add_banner_to_container() anchor (kivymd.uix.card.MDCardSwipe attribute), 190
(kivymd.uix.banner.MDBanner method), anchor (kivymd.uix.navigationdrawer.MDNavigationDrawer
40 attribute), 92
add_blur() (in module kivymd.utils.cropimage), 264 anchor_title (kivymd.uix.toolbar.MDToolbar
add_corners() (in module kivymd.utils.cropimage), attribute), 103
264 anim_complete() (kivymd.uix.behaviors.ripplebehavior.CommonRipple
add_item() (kivymd.uix.bottomsheet.MDGridBottomSheet method), 234
method), 67 anim_duration (kivymd.uix.tab.MDTabs attribute),
281
KivyMD, Release 0.104.2.dev0
50 attribute), 242
anim_rect() (kivymd.uix.textfield.MDTextFieldRect background_palette
method), 155 (kivymd.uix.behaviors.backgroundcolorbehavior.SpecificBackgrou
anim_threshold (kivymd.uix.tab.MDTabs attribute), attribute), 238
50 background_palette
animation (kivymd.uix.bottomsheet.MDBottomSheet (kivymd.uix.button.MDFloatingActionButton
attribute), 64 attribute), 131
animation_display_banner() BackgroundColorBehavior (class in
(kivymd.uix.banner.MDBanner method), kivymd.uix.behaviors.backgroundcolorbehavior),
41 236
animation_label() BaseListItem (class in kivymd.uix.list), 171
(kivymd.uix.button.MDTextButton method), bg_color (kivymd.uix.bottomsheet.MDBottomSheet at-
131 tribute), 64
animation_to_bottom() bg_color (kivymd.uix.list.BaseListItem attribute), 172
(kivymd.uix.useranimationcard.MDUserAnimationCard
bg_color_root_button
method), 85 (kivymd.uix.button.MDFloatingActionButtonSpeedDial
animation_to_top() attribute), 134
(kivymd.uix.useranimationcard.MDUserAnimationCard
bg_color_stack_button
method), 85 (kivymd.uix.button.MDFloatingActionButtonSpeedDial
animation_tooltip_show() attribute), 134
(kivymd.uix.tooltip.MDTooltip method), 201 bg_dark (kivymd.theming.ThemeManager attribute), 12
animtion_icon_close() bg_darkest (kivymd.theming.ThemeManager at-
(kivymd.uix.backdrop.MDBackdrop method), tribute), 11
205 bg_hint_color (kivymd.uix.button.MDFloatingActionButtonSpeedDial
animtion_icon_menu() attribute), 134
(kivymd.uix.backdrop.MDBackdrop method), bg_light (kivymd.theming.ThemeManager attribute),
205 13
ArgumentParserWithHelp (class in bg_normal (kivymd.theming.ThemeManager attribute),
kivymd.tools.release.argument_parser), 259 12
bind() (kivymd.utils.asynckivy.event method), 264
B body (kivymd.stiffscroll.StiffScrollEffect attribute), 253
border_margin (kivymd.uix.menu.MDDropdownMenu
b (kivymd.uix.behaviors.backgroundcolorbehavior.BackgroundColorBehavior
attribute), 237 attribute), 118
back() (kivymd.uix.filemanager.MDFileManager border_point (kivymd.uix.behaviors.hover_behavior.HoverBehavior
method), 199 attribute), 230
background (kivymd.uix.bottomsheet.MDBottomSheet box_color (kivymd.uix.imagelist.SmartTile attribute),
attribute), 64 144
background (kivymd.uix.card.MDCard attribute), 189 box_content (kivymd.uix.useranimationcard.MDUserAnimationCard
background_color (kivymd.uix.backdrop.MDBackdrop attribute), 84
attribute), 205 box_position (kivymd.uix.imagelist.SmartTile
background_color (kivymd.uix.datatables.MDDataTable attribute), 144
attribute), 215 build() (kivymd.vendor.circularTimePicker.Example
background_color (kivymd.uix.menu.MDDropdownMenu method), 275
attribute), 118 button_callback (kivymd.uix.snackbar.Snackbar at-
background_color (kivymd.uix.picker.MDDatePicker tribute), 36
attribute), 58 button_color (kivymd.uix.snackbar.Snackbar at-
background_color (kivymd.uix.tab.MDTabs at- tribute), 36
tribute), 50 button_text (kivymd.uix.snackbar.Snackbar at-
tribute), 36
background_down (kivymd.uix.behaviors.toggle_behavior.MDToggleButton
attribute), 242 buttons (kivymd.uix.dialog.MDDialog attribute), 76
background_hue (kivymd.uix.behaviors.backgroundcolorbehavior.SpecificBackgroundColorBehavior
attribute), 238 C
background_normal cal_layout (kivymd.uix.picker.MDDatePicker at-
(kivymd.uix.behaviors.toggle_behavior.MDToggleButton tribute), 58
282 Index
KivyMD, Release 0.104.2.dev0
Index 283
KivyMD, Release 0.104.2.dev0
284 Index
KivyMD, Release 0.104.2.dev0
disabled_hint_text_color errors_background_color
(kivymd.theming.ThemeManager attribute), 14 (kivymd.utils.hot_reload_viewer.HotReloadViewer
dismiss() (kivymd.uix.menu.MDDropdownMenu attribute), 269
method), 119 errors_text_color
displacement (kivymd.stiffscroll.StiffScrollEffect at- (kivymd.utils.hot_reload_viewer.HotReloadErrorText
tribute), 253 attribute), 268
display_tooltip() (kivymd.uix.tooltip.MDTooltip errors_text_color
method), 201 (kivymd.utils.hot_reload_viewer.HotReloadViewer
divider (kivymd.uix.list.BaseListItem attribute), 172 attribute), 269
divider_color (kivymd.theming.ThemeManager at- event (class in kivymd.utils.asynckivy), 264
tribute), 13 Example (class in kivymd.vendor.circularTimePicker),
do_animation_open_stack() 275
(kivymd.uix.button.MDFloatingActionButtonSpeedDial
exit_manager (kivymd.uix.filemanager.MDFileManager
method), 135 attribute), 198
do_layout() (kivymd.vendor.circleLayout.CircularLayout export_icon_definitions() (in module
method), 270 kivymd.tools.release.update_icons), 261
dot_is_none() (kivymd.vendor.circularTimePicker.CircularNumberPicker
ext (kivymd.uix.filemanager.MDFileManager attribute),
method), 273 198
download_file() (in module
kivymd.tools.release.update_icons), 261 F
dp (in module kivymd.material_resources), 252 fade_in() (kivymd.toast.kivytoast.kivytoast.Toast
drag_threshold (kivymd.stiffscroll.StiffScrollEffect method), 256
attribute), 253 fade_out() (kivymd.toast.kivytoast.kivytoast.Toast
draw_shadow (kivymd.uix.taptargetview.MDTapTargetView method), 256
attribute), 226 fade_out() (kivymd.uix.behaviors.ripplebehavior.CommonRipple
duration (kivymd.toast.kivytoast.kivytoast.Toast at- method), 234
tribute), 256 fill_color (kivymd.uix.textfield.MDTextField at-
duration (kivymd.uix.snackbar.Snackbar attribute), 36 tribute), 157
duration_long_touch finish_ripple() (kivymd.uix.behaviors.ripplebehavior.CommonRipple
(kivymd.uix.behaviors.touch_behavior.TouchBehavior method), 234
attribute), 228 first_widget (kivymd.uix.bottomnavigation.MDBottomNavigation
duration_opening (kivymd.uix.bottomsheet.MDBottomSheet attribute), 31
attribute), 64 FitImage (class in kivymd.utils.fitimage), 266
fmt_lbl_date() (kivymd.uix.picker.MDDatePicker
E method), 58
edit_padding_for_item() focus_behavior (kivymd.uix.behaviors.focus_behavior.FocusBehavior
(kivymd.uix.dialog.MDDialog method), 82 attribute), 231
focus_behavior (kivymd.uix.card.MDCard at-
elevation (kivymd.uix.behaviors.elevation.CommonElevationBehavior
attribute), 240 tribute), 189
elevation (kivymd.uix.card.MDCard attribute), 189 focus_color (kivymd.uix.behaviors.focus_behavior.FocusBehavior
elevation (kivymd.uix.tab.MDTabs attribute), 50 attribute), 231
elevation (kivymd.uix.toolbar.MDToolbar attribute), FocusBehavior (class in
103 kivymd.uix.behaviors.focus_behavior), 231
font_color_down (kivymd.uix.behaviors.toggle_behavior.MDToggleBu
enable_swiping (kivymd.uix.navigationdrawer.MDNavigationDrawer
attribute), 92 attribute), 242
error (kivymd.uix.textfield.MDTextField attribute), 157 font_color_normal
(kivymd.uix.behaviors.toggle_behavior.MDToggleButton
error() (kivymd.tools.release.argument_parser.ArgumentParserWithHelp
method), 259 attribute), 242
error_color (kivymd.theming.ThemeManager at- font_name (kivymd.uix.tab.MDTabs attribute), 50
tribute), 14 font_path (in module
error_color (kivymd.uix.textfield.MDTextField at- kivymd.tools.release.update_icons), 261
tribute), 157 font_size (kivymd.uix.dropdownitem.MDDropDownItem
errors (kivymd.utils.hot_reload_viewer.HotReloadViewer attribute), 53
attribute), 269
Index 285
KivyMD, Release 0.104.2.dev0
286 Index
KivyMD, Release 0.104.2.dev0
Index 287
KivyMD, Release 0.104.2.dev0
288 Index
KivyMD, Release 0.104.2.dev0
Index 289
KivyMD, Release 0.104.2.dev0
290 Index
KivyMD, Release 0.104.2.dev0
Index 291
KivyMD, Release 0.104.2.dev0
26 method), 135
on_action_button() on_color_mode() (kivymd.uix.textfield.MDTextField
(kivymd.uix.toolbar.MDToolbar method), method), 157
104 on_data() (kivymd.uix.button.MDFloatingActionButtonSpeedDial
on_active() (kivymd.uix.selectioncontrol.MDCheckbox method), 135
method), 141 on_description_text()
on_active() (kivymd.uix.slider.MDSlider method), (kivymd.uix.taptargetview.MDTapTargetView
161 method), 226
on_active() (kivymd.uix.spinner.MDSpinner on_description_text_bold()
method), 26 (kivymd.uix.taptargetview.MDTapTargetView
on_adaptive_height() method), 227
(kivymd.uix.MDAdaptiveWidget method), on_description_text_size()
263 (kivymd.uix.taptargetview.MDTapTargetView
on_adaptive_size() method), 226
(kivymd.uix.MDAdaptiveWidget method), on_disabled() (kivymd.uix.button.MDFillRoundFlatButton
263 method), 132
on_adaptive_width() on_disabled() (kivymd.uix.button.MDRectangleFlatButton
(kivymd.uix.MDAdaptiveWidget method), method), 131
263 on_disabled() (kivymd.uix.button.MDTextButton
on_ampm() (kivymd.vendor.circularTimePicker.CircularTimePicker method), 131
method), 274 on_dismiss() (kivymd.uix.bottomsheet.MDBottomSheet
on_anchor() (kivymd.uix.card.MDCardSwipe method), 65
method), 191 on_dismiss() (kivymd.uix.menu.MDDropdownMenu
on_any_event() (kivymd.utils.hot_reload_viewer.HotReloadHandlermethod), 119
method), 268 on_double_tap() (kivymd.uix.behaviors.touch_behavior.TouchBehavio
on_bg_color_root_button() method), 228
(kivymd.uix.button.MDFloatingActionButtonSpeedDial
on_draw_shadow() (kivymd.uix.taptargetview.MDTapTargetView
method), 135 method), 226
on_bg_color_stack_button() on_elevation() (kivymd.uix.button.MDFillRoundFlatButton
(kivymd.uix.button.MDFloatingActionButtonSpeedDial method), 132
method), 135 on_enter() (kivymd.uix.behaviors.focus_behavior.FocusBehavior
on_bg_hint_color() method), 231
(kivymd.uix.button.MDFloatingActionButtonSpeedDial
on_enter() (kivymd.uix.behaviors.hover_behavior.HoverBehavior
method), 135 method), 230
on_carousel_index() (kivymd.uix.tab.MDTabs on_enter() (kivymd.uix.button.MDFloatingActionButtonSpeedDial
method), 51 method), 135
on_check_press() (kivymd.uix.datatables.MDDataTable on_enter() (kivymd.uix.menu.MDDropdownMenu
method), 215 method), 119
on_close() (kivymd.uix.backdrop.MDBackdrop on_enter() (kivymd.uix.tooltip.MDTooltip method),
method), 205 201
on_close() (kivymd.uix.button.MDFloatingActionButtonSpeedDial
on_error() (kivymd.utils.hot_reload_viewer.HotReloadViewer
method), 135 method), 269
on_close() (kivymd.uix.expansionpanel.MDExpansionPanelon_errors_text_color()
method), 97 (kivymd.utils.hot_reload_viewer.HotReloadViewer
on_close() (kivymd.uix.taptargetview.MDTapTargetView method), 269
method), 226 on_focus() (kivymd.uix.textfield.MDTextField
on_color_active() method), 157
(kivymd.uix.textfield.MDTextFieldRound on_focus() (kivymd.uix.textfield.MDTextFieldRound
method), 159 method), 159
on_color_icon_root_button() on_header() (kivymd.uix.backdrop.MDBackdrop
(kivymd.uix.button.MDFloatingActionButtonSpeedDial method), 205
method), 135 on_hint() (kivymd.uix.slider.MDSlider method), 161
on_color_icon_stack_button() on_hint_animation()
(kivymd.uix.button.MDFloatingActionButtonSpeedDial (kivymd.uix.button.MDFloatingActionButtonSpeedDial
292 Index
KivyMD, Release 0.104.2.dev0
Index 293
KivyMD, Release 0.104.2.dev0
294 Index
KivyMD, Release 0.104.2.dev0
Index 295
KivyMD, Release 0.104.2.dev0
296 Index
KivyMD, Release 0.104.2.dev0
Index 297
KivyMD, Release 0.104.2.dev0
298 Index
KivyMD, Release 0.104.2.dev0
set_selected_widget() (kivymd.uix.behaviors.backgroundcolorbehavior.SpecificBackgrou
(kivymd.uix.picker.MDDatePicker method), attribute), 238
58 specific_text_color
set_shadow() (kivymd.uix.toolbar.MDToolbar (kivymd.uix.behaviors.backgroundcolorbehavior.SpecificBackgrou
method), 104 attribute), 238
set_spinner() (kivymd.uix.refreshlayout.RefreshSpinner SpecificBackgroundColorBehavior (class in
method), 147 kivymd.uix.behaviors.backgroundcolorbehavior),
set_state() (kivymd.uix.navigationdrawer.MDNavigationDrawer237
method), 93 spinner_color (kivymd.uix.refreshlayout.RefreshSpinner
set_time() (kivymd.uix.picker.MDTimePicker attribute), 147
method), 58 standard_increment
set_time() (kivymd.vendor.circularTimePicker.CircularTimePicker(kivymd.theming.ThemeManager attribute), 14
method), 274 stars (kivymd.uix.imagelist.SmartTileWithStar at-
set_type_banner() (kivymd.uix.banner.MDBanner tribute), 145
method), 40 start() (in module kivymd.utils.asynckivy), 264
shake() (kivymd.uix.behaviors.magic_behavior.MagicBehavior
start() (kivymd.stiffscroll.StiffScrollEffect method),
method), 236 254
sheet_list (kivymd.uix.bottomsheet.MDListBottomSheetstart() (kivymd.uix.progressbar.MDProgressBar
attribute), 66 method), 71
show() (kivymd.uix.banner.MDBanner method), 40 start() (kivymd.uix.taptargetview.MDTapTargetView
show() (kivymd.uix.filemanager.MDFileManager method), 226
method), 199 start() (kivymd.utils.fpsmonitor.FpsMonitor method),
show() (kivymd.uix.snackbar.Snackbar method), 37 267
show_error() (kivymd.utils.hot_reload_viewer.HotReloadViewer
start_angle (kivymd.vendor.circleLayout.CircularLayout
method), 269 attribute), 270
show_hidden_files start_anim_spinner()
(kivymd.uix.filemanager.MDFileManager (kivymd.uix.refreshlayout.RefreshSpinner
attribute), 198 method), 147
show_off (kivymd.uix.slider.MDSlider attribute), 161 start_ripple() (kivymd.uix.behaviors.ripplebehavior.CommonRipple
shown_items (kivymd.vendor.circularTimePicker.CircularNumberPicker
method), 234
attribute), 273 state (kivymd.uix.button.MDFloatingActionButtonSpeedDial
shrink() (kivymd.uix.behaviors.magic_behavior.MagicBehavior attribute), 134
method), 236 state (kivymd.uix.card.MDCardSwipe attribute), 190
size_factor (kivymd.vendor.circularTimePicker.Numberstate (kivymd.uix.navigationdrawer.MDNavigationDrawer
attribute), 272 attribute), 92
sleep() (in module kivymd.utils.asynckivy), 264 state (kivymd.uix.taptargetview.MDTapTargetView at-
SmartTile (class in kivymd.uix.imagelist), 144 tribute), 226
SmartTileWithLabel (class in status (kivymd.uix.navigationdrawer.MDNavigationDrawer
kivymd.uix.imagelist), 144 attribute), 92
SmartTileWithStar (class in kivymd.uix.imagelist), StiffScrollEffect (class in kivymd.stiffscroll), 253
145 stop() (kivymd.stiffscroll.StiffScrollEffect method), 254
Snackbar (class in kivymd.uix.snackbar), 36 stop() (kivymd.uix.progressbar.MDProgressBar
sort (kivymd.uix.datatables.MDDataTable attribute), method), 71
212 stop() (kivymd.uix.taptargetview.MDTapTargetView
sort_by (kivymd.uix.filemanager.MDFileManager at- method), 226
tribute), 199 stop_on_outer_touch
sort_by_desc (kivymd.uix.filemanager.MDFileManager (kivymd.uix.taptargetview.MDTapTargetView
attribute), 199 attribute), 226
source (kivymd.uix.bottomsheet.GridBottomSheetItem stop_on_target_touch
attribute), 66 (kivymd.uix.taptargetview.MDTapTargetView
source (kivymd.uix.imagelist.SmartTile attribute), 144 attribute), 226
source (kivymd.uix.label.MDIcon attribute), 179 swipe_distance (kivymd.uix.card.MDCardSwipe at-
source (kivymd.utils.fitimage.FitImage attribute), 266 tribute), 190
specific_secondary_text_color swipe_distance (kivymd.uix.navigationdrawer.MDNavigationDrawer
Index 299
KivyMD, Release 0.104.2.dev0
300 Index
KivyMD, Release 0.104.2.dev0
Index 301
KivyMD, Release 0.104.2.dev0
302 Index