Tile

The tile element is a small TileElement. It comes with an icon, text and a title. It may be a little rough to use still since it was designed before the tile base element was written. See the tutorial on Tiles for an explainer of working with the tile_layout property.

class Tile

Element that combines an icon, text and optional title into a versatile element.

A lot of defaults are present, such that making custom layout elements combining icons and text is generally not needed.

Available element tiles are:
icon, title, text
Shorthand tile_layout values are:
  • vertical: "icon;title;text"

  • horizontal: "icon,[title;text]"

Available shorthand actions are:
  • generate: Generates the element’s image data.

  • update: Function to update an element via actions.

Element Properties

property icon: str | Image | None

Required. The current icon. Can be set to a str (either an mdi icon or image file), or a PIL image instance directly. If the latter, the image will still be treated as an image file i.e. any icon settings etc. are applied to it regardless (This does also mean you don’t need to worry about sizing, as that is also taken care of). Can also be set to None for no icon.

property text: str | None

Required. The text displayed on the Tile.

property accent_color: str | int | list | tuple[L, A] | tuple[R, G, B] | tuple[R, G, B, A]
Accent color to style child elements. Not inherently used in the layout itself, but can be used in child elements, to give them a uniform style Set a color_property of one to “accent” to do so.
Optional, defaults to "gray"
property background_color: str | int | list | tuple[L, A] | tuple[R, G, B] | tuple[R, G, B, A] | None
Background color of the element. Automatically set to None if background_shape is used.
Optional, defaults to "white"
property foreground_color: str | int | list | tuple[L, A] | tuple[R, G, B] | tuple[R, G, B, A]
Foreground color to style child elements Additional color property for Layouts. Not inherently used in the layout itself, but can be used in child elements, to give them a uniform style. Set a color_property of one to “foreground” to do so.
Optional, defaults to "black"
property outline_color: str | int | list | tuple[L, A] | tuple[R, G, B] | tuple[R, G, B, A] | None
Color of the layout’s outline. Set to None to use no outline.
Optional, defaults to None
property hold_action: str | Callable[[Element, InteractEvent, Any], Any] | None
The function called when the element is held. Set to None to have nothing called. If set to a dict, the values for hold_action_data and hold_action_map will be overwritten if the respective key is present.
Optional, defaults to None
property hold_release_action: str | Callable[[Element, InteractEvent, Any], Any] | None
The function called when the element is released from being held down. This function is only available on devices with the HOLD_RELEASE feature. Set to None to have nothing called. If set to a dict, the values for hold_release_action_data and hold_release_action_map will be overwritten if the respective key is present.
Optional, defaults to None
property tap_action: str | Callable[[Element, InteractEvent, Any], Any] | None
The function called when the element is tapped. Set to None to have nothing called. If set to a dict, the values for tap_action_data and tap_action_map will be overwritten if the respective key is present.
Optional, defaults to None
property background_shape: Literal['circle', 'square', 'rounded_square', 'rounded_rectangle', 'octagon', 'hexagon', 'ADVANCED'] | None
The shape to apply to the button background. Keep in mind some square shapes won’t automatically fit the shape. The shape takes the background colour.
Optional, defaults to "default"
property badge_icon: mdi:icon | None
Icon to use as a badge for the Tile’s Icon element. Must be None or an mdi icon.
Optional, defaults to None
property badge_location: Literal['UR', 'LR', 'UL', 'LL']
The location of the badge. Can be Can be one of UR, LR, UL or LL (Upper Right, Lower Right, Upper Left, Lower Left). Also accepts the fully written strings, but will be set to the abbreviated location.
Optional, defaults to "UR"
property badge_settings: dict
Dict with settings to apply to the badge. background_color needs to be defined explicitly, otherwise it is automatically set to the background color or default color.
Optional, defaults to {}
property element_properties: dict[str, dict]
Dict with properties for each element. Accepts parsing colors. Use as nested dicts, the first key specifying the element tag, with the dict within denoting the properties to set.
Optional, defaults to {'icon': {'icon_color': 'foreground'}, 'text': {'font_color': 'foreground'}, 'title': {'font': 'header', 'font_color': 'foreground'}}
property feedback_duration: duration
Duration of the element’s feedback function The time an element will stay in ‘feedback state’, before returning to its normal state. Can be set to a string, which will be parsed to the right amount of seconds.
Optional, defaults to 0.75
property hide: tuple[str]
Elements that will be explicitly removed from the layout parsed from tile_layout. Set to None, or an empty iterable to hide nothing. Elements can also be hidden by simply omitting them from the tile_layout.
Optional, defaults to ()
property horizontal_sizes: _EltSizeDict
Horizontal sizes for the elements. Returns the default values when set to default, not ‘default’.
Optional, defaults to "default"
property outline_width: str | int | float
Width of the outline of the encompassing rectangle.
Optional, defaults to 0
property radius: str | int | float
Corner radius of the element’s background. Only applicable when no background shape is used, otherwise 0.
Optional, defaults to 0
property shape_settings: dict
Settings to apply to the tile background. background_color and outline_color/width are set from the properties if not present. If backgroundshape is ADVANCED, you are responsible for all settings yourself, as well as specifying the drawing method to use.
Optional, defaults to {}
property tile_layout: Literal['vertical', 'horizontal'] | LayoutString
String used to set the layout. None if the layout was set directly.
Optional, defaults to "vertical"
property title: str | None
The title text displayed on the above the Tile text. Set to None to not include it.
Optional, defaults to None
property vertical_sizes: _EltSizeDict
Vertical sizes for the elements. Returns the default values when set to default, not ‘default’.
Optional, defaults to "default"
property icon: str | Image | None

Required

property text: str | None

Required

property accent_color: str | int | list | tuple[L, A] | tuple[R, G, B] | tuple[R, G, B, A]

Optional, defaults to "gray"

property background_color: str | int | list | tuple[L, A] | tuple[R, G, B] | tuple[R, G, B, A] | None

Optional, defaults to "white"

property foreground_color: str | int | list | tuple[L, A] | tuple[R, G, B] | tuple[R, G, B, A]

Optional, defaults to "black"

property outline_color: str | int | list | tuple[L, A] | tuple[R, G, B] | tuple[R, G, B, A] | None

Optional, defaults to None

property hold_action: str | Callable[[Element, InteractEvent, Any], Any] | None

Optional, defaults to None

property hold_release_action: str | Callable[[Element, InteractEvent, Any], Any] | None

Optional, defaults to None

property tap_action: str | Callable[[Element, InteractEvent, Any], Any] | None

Optional, defaults to None

property background_shape: Literal['circle', 'square', 'rounded_square', 'rounded_rectangle', 'octagon', 'hexagon', 'ADVANCED'] | None

Optional, defaults to "default"

property badge_icon: mdi:icon | None

Optional, defaults to None

property badge_location: Literal['UR', 'LR', 'UL', 'LL']

Optional, defaults to "UR"

property badge_settings: dict

Optional, defaults to {}

property element_properties: dict[str, dict]

Optional, defaults to {'icon': {'icon_color': 'foreground'}, 'text': {'font_color': 'foreground'}, 'title': {'font': 'header', 'font_color': 'foreground'}}

property feedback_duration: duration

Optional, defaults to 0.75

property hide: tuple[str]

Optional, defaults to ()

property horizontal_sizes: _EltSizeDict

Optional, defaults to "default"

property outline_width: str | int | float

Optional, defaults to 0

property radius: str | int | float

Optional, defaults to 0

property shape_settings: dict

Optional, defaults to {}

property tile_layout: Literal['vertical', 'horizontal'] | LayoutString

Optional, defaults to "vertical"

property title: str | None

Optional, defaults to None

property vertical_sizes: _EltSizeDict

Optional, defaults to "default"

  • icon, Required. The current icon. Can be set to a str (either an mdi icon or image file), or a PIL image instance directly.

  • text, Required. The text displayed on the Tile

  • accent_color, Optional, defaults to "gray". Accent color to style child elements.

  • background_color, Optional, defaults to "white". Background color of the element. Automatically set to None if background_shape is used.

  • foreground_color, Optional, defaults to "black". Foreground color to style child elements

  • outline_color, Optional, defaults to None. Color of the layout’s outline.

  • hold_action, Optional, defaults to None. The function called when the element is held.

  • hold_release_action, Optional, defaults to None. The function called when the element is released from being held down.

  • tap_action, Optional, defaults to None. The function called when the element is tapped.

  • background_shape, Optional, defaults to "default". The shape to apply to the button background. Keep in mind some square shapes won’t automatically fit the shape.

  • badge_icon, Optional, defaults to None. Icon to use as a badge for the Tile’s Icon element. Must be None or an mdi icon

  • badge_location, Optional, defaults to "UR". The location of the badge.

  • badge_settings, Optional, defaults to {}. Dict with settings to apply to the badge. background_color needs to be defined explicitly, otherwise it is automatically set to the background color or default color.

  • element_properties, Optional, defaults to {'icon': {'icon_color': 'foreground'}, 'text': {'font_color': 'foreground'}, 'title': {'font': 'header', 'font_color': 'foreground'}}. Dict with properties for each element.

  • feedback_duration, Optional, defaults to 0.75. Duration of the element’s feedback function

  • hide, Optional, defaults to (). Elements that will be explicitly removed from the layout parsed from tile_layout.

  • horizontal_sizes, Optional, defaults to "default". Horizontal sizes for the elements. Returns the default values when set to default, not ‘default’

  • outline_width, Optional, defaults to 0. Width of the outline of the encompassing rectangle

  • radius, Optional, defaults to 0. Corner radius of the element’s background. Only applicable when no background shape is used, otherwise 0.

  • shape_settings, Optional, defaults to {}. Settings to apply to the tile background. background_color and outline_color/width are set from the properties if not present.

  • tile_layout, Optional, defaults to "vertical". String used to set the layout.

  • title, Optional, defaults to None. The title text displayed on the above the Tile text. Set to None to not include it.

  • vertical_sizes, Optional, defaults to "default". Vertical sizes for the elements. Returns the default values when set to default, not ‘default’