ImageList#
#
See also
Image lists display a collection of images in an organized grid.
Usage#
MDSmartTile:
[...]
MDSmartTileImage:
[...]
MDSmartTileOverlayContainer:
[...]
# Content
[...]
Anatomy#
Example#
from kivy.lang import Builder
from kivymd.app import MDApp
KV = '''
MDScreen:
md_bg_color: self.theme_cls.backgroundColor
MDSmartTile:
pos_hint: {"center_x": .5, "center_y": .5}
size_hint: None, None
size: "320dp", "320dp"
overlap: False
MDSmartTileImage:
source: "bg.jpg"
radius: [dp(24), dp(24), 0, 0]
MDSmartTileOverlayContainer:
md_bg_color: 0, 0, 0, .5
adaptive_height: True
padding: "8dp"
spacing: "8dp"
radius: [0, 0, dp(24), dp(24)]
MDIconButton:
icon: "heart-outline"
theme_icon_color: "Custom"
icon_color: 1, 0, 0, 1
pos_hint: {"center_y": .5}
on_release:
self.icon = "heart" \
if self.icon == "heart-outline" else \
"heart-outline"
MDLabel:
text: "Ibanez GRG121DX-BKF"
theme_text_color: "Custom"
text_color: "white"
'''
class Example(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
return Builder.load_string(KV)
Example().run()
API break#
1.2.0 version#
MDSmartTile:
[...]
# Content.
MDIconButton:
[...]
MDLabel:
[...]
2.0.0 version#
MDSmartTile:
[...]
MDSmartTileImage:
[...]
MDSmartTileOverlayContainer:
[...]
# Content.
[...]
API - kivymd.uix.imagelist.imagelist
#
- class kivymd.uix.imagelist.imagelist.MDSmartTileImage(**kwargs)#
Implements the tile image.
Changed in version 2.0.0: The SmartTileImage class has been renamed to MDSmartTileImage.
For more information, see in the
RectangularRippleBehavior
andButtonBehavior
andFitImage
classes documentation.
- class kivymd.uix.imagelist.imagelist.MDSmartTileOverlayContainer(*args, **kwargs)#
Implements a container for custom widgets to be added to the tile.
Changed in version 2.0.0: The SmartTileOverlayBox class has been renamed to MDSmartTileOverlayContainer.
For more information, see in the
BoxLayout
class documentation.
- class kivymd.uix.imagelist.imagelist.MDSmartTile(**kwargs)#
A tile for more complex needs.
For more information, see in the
MDRelativeLayout
class documentation.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.
- 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).
- overlay_mode#
Determines weather the information box acts as a header or footer to the image. Available are options: ‘footer’, ‘header’.
Changed in version 2.0.0: The box_position attribute has been renamed to overlay_mode.
overlay_mode
is aOptionProperty
and defaults to ‘footer’.
- overlap#
Determines if the header/footer overlaps on top of the image or not.
overlap
is aBooleanProperty
and defaults to True.
- on_release(*args)#
Fired when the button is released (i.e. the touch/click that pressed the button goes away).
- on_press(*args)#
Fired when the button is pressed.
- add_widget(widget, *args, **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 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)