Counter¶
The counter element provides a tile based layout to show a counter, including buttons to increment and decrement the value.
- class Counter¶
Tile based element that can increment a numeric value with two buttons.
Available element tiles are:count,up,down- Shorthand
tile_layoutvalues are: default:"count,[up;down]"horizontal:"down,count,up"
- Available shorthand actions are:
generate: Generates the element’s image data.update: Function to update an element via actions.set-value: set the counter value directly. Values are rounded down according to stepincrement: Increments the counters valuedecrement: Decrements the counter value
Element Properties
- 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
- Color of the element background.Optional, defaults to
None
- 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 on_count: Callable[[Counter, float | int], Any]
- Function that is called when the counter value changes. Passes the counter itself and the new value.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 downIcon: mdi:icon
- The icon to show on the up button.Optional, defaults to
"mdi:minus-box"
- 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
{'count': {}, 'up': {'icon_color': 'foreground'}, 'down': {'icon_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 horizontal_sizes: dict[str, str | int | float]
- Horizontal sizing of the tiles. Setting this will update from the current values, not overwrite it.Optional, defaults to
None
- property maximum: float
- The maximum value of the counter. Set to None for no maximum.Optional, defaults to
None
- property minimum: float | None
- The minimum value of the counter. Set to None for no minimum.Optional, defaults to
None
- 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 outlining rectangle.Optional, defaults to
0
- property roundDigits: int
- Amount of digits to round of the new value to. Defaults to the amount in step.Optional, defaults to
None
- property step: float
- The value with which to increase/decrease the counter when calling increment/decrement.Optional, defaults to
1
- property tile_layout: str | None
- String used to set the layout. None if the layout was set directly.Optional, defaults to
"default"
- property upIcon: mdi:icon
- The icon to show on the up button.Optional, defaults to
"mdi:plus-box"
- property value: float
- The current value of the counter.Optional, defaults to
0
- property vertical_sizes: dict[str, str | int | float]
- Vertical sizing of the tiles. Setting this will update from the current values, not overwrite it.Optional, defaults to
None
- 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
None
- 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 on_count: Callable[[Counter, float | int], Any]
Optional, defaults to
None
- property tap_action: str | Callable[[Element, InteractEvent, Any], Any] | None
Optional, defaults to
None
- property downIcon: mdi:icon
Optional, defaults to
"mdi:minus-box"
- property element_properties: dict[str, dict]
Optional, defaults to
{'count': {}, 'up': {'icon_color': 'foreground'}, 'down': {'icon_color': 'foreground'}}
- property feedback_duration: duration
Optional, defaults to
0.75
- property horizontal_sizes: dict[str, str | int | float]
Optional, defaults to
None
- property maximum: float
Optional, defaults to
None
- property minimum: float | None
Optional, defaults to
None
- property outline_width: str | int | float
Optional, defaults to
0
- property radius: str | int | float
Optional, defaults to
0
- property roundDigits: int
Optional, defaults to
None
- property step: float
Optional, defaults to
1
- property tile_layout: str | None
Optional, defaults to
"default"
- property upIcon: mdi:icon
Optional, defaults to
"mdi:plus-box"
- property value: float
Optional, defaults to
0
- property vertical_sizes: dict[str, str | int | float]
Optional, defaults to
None
accent_color, Optional, defaults to"gray". Accent color to style child elements.background_color, Optional, defaults toNone. Color of the element background.foreground_color, Optional, defaults to"black". Foreground color to style child elementsoutline_color, Optional, defaults toNone. Color of the layout’s outline.hold_action, Optional, defaults toNone. The function called when the element is held.hold_release_action, Optional, defaults toNone. The function called when the element is released from being held down.on_count, Optional, defaults toNone. Function that is called when the counter value changes. Passes the counter itself and the new value.tap_action, Optional, defaults toNone. The function called when the element is tapped.downIcon, Optional, defaults to"mdi:minus-box". The icon to show on the up buttonelement_properties, Optional, defaults to{'count': {}, 'up': {'icon_color': 'foreground'}, 'down': {'icon_color': 'foreground'}}. Dict with properties for each element.feedback_duration, Optional, defaults to0.75. Duration of the element’s feedback functionhorizontal_sizes, Optional, defaults toNone. Horizontal sizing of the tiles.maximum, Optional, defaults toNone. The maximum value of the counter. Set to None for no maximumminimum, Optional, defaults toNone. The minimum value of the counter. Set to None for no minimumoutline_width, Optional, defaults to0. Width of the outline of the encompassing rectangleradius, Optional, defaults to0. Corner radius of the outlining rectangleroundDigits, Optional, defaults toNone. Amount of digits to round of the new value to. Defaults to the amount in step.step, Optional, defaults to1. The value with which to increase/decrease the counter when calling increment/decrementtile_layout, Optional, defaults to"default". String used to set the layout.upIcon, Optional, defaults to"mdi:plus-box". The icon to show on the up buttonvalue, Optional, defaults to0. The current value of the countervertical_sizes, Optional, defaults toNone. Vertical sizing of the tiles.
- Shorthand