Backdrop¶
See also
Skeleton layout for using MDBackdrop
:
Usage¶
<Root>:
MDBackdrop:
MDBackdropBackLayer:
ContentForBackdropBackLayer:
MDBackdropFrontLayer:
ContentForBackdropFrontLayer:
Example¶
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen
from kivymd.app import MDApp
# 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_logo.png"
pos_hint: {"center_x": .5, "center_y": .6}
'''
)
# Usage example of MDBackdrop.
Builder.load_string(
'''
<ExampleBackdrop>
MDBackdrop:
id: backdrop
left_action_items: [['menu', lambda x: self.open()]]
title: "Example Backdrop"
header_text: "Menu:"
MDBackdropBackLayer:
MyBackdropBackLayer:
id: backlayer
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()
Note
API - kivymd.uix.backdrop
¶
-
class
kivymd.uix.backdrop.
MDBackdrop
(**kwargs)¶ - Events
-
padding
¶ Padding for contents of the front layer.
padding
is anListProperty
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 information, see thekivymd.uix.toolbar.MDToolbar
module andleft_action_items
parameter.left_action_items
is anListProperty
and defaults to [].
-
right_action_items
¶ Works the same way as
left_action_items
.right_action_items
is anListProperty
and defaults to [].
-
title
¶ See the
kivymd.uix.toolbar.MDToolbar.title
parameter.title
is anStringProperty
and defaults to ‘’.
-
background_color
¶ Background color of back layer.
background_color
is anListProperty
and defaults to [].
-
radius
¶ The value of the rounding radius of the upper left corner of the front layer.
radius
is anNumericProperty
and defaults to 25.
-
header
¶ Whether to use a header above the contents of the front layer.
header
is anBooleanProperty
and defaults to True.
-
header_text
¶ Text of header.
header_text
is anStringProperty
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 anStringProperty
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_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 hierarchy, 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.
- widget:
>>> from kivy.uix.button import Button >>> from kivy.uix.slider import Slider >>> root = Widget() >>> root.add_widget(Button()) >>> slider = Slider() >>> root.add_widget(slider)
-
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.