inkBoard inkBoard inkBoard
  • Tutorial
    • Cheatsheet A quick reference for core concepts
  • Documentation
    • Configuration
    • Elements
    • Platforms
    • Integrations
/

Documentation

  • Documentation
  • Types
  • Configuration
  • Elements
    • Button
    • Picture & Icon
    • Tile
    • Sliders
    • CheckBoxes
    • Clocks
    • Counter
    • Dropdown
    • Layouts
    • Popups
    • Menu Elements
    • Device Elements
    • Base Elements
  • Platforms
    • Desktop
      • Desktop
      • Readme
    • Kobo
      • Kobo
      • Readme
    • Developing
  • Integrations
    • Home Assistant
      • Elements
      • Examples
    • Meteocons
    • System Tray
    • Developing
  • Designer
  • Command Line

On this page

  • DropDown
Slalamander/inkBoard 0 0
  1. inkBoard /
  2. Site Index /
  3. Elements /
  4. Dropdown

Dropdown¶

The DropDown element is a Button, which allows selecting a new value via a popup that opens when tapping it.

class DropDown¶

Text element which opens a dropdown menu showing options to select.

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

  • update: Function to update an element via actions.

  • select: Async function that handles selecting an option in the menu item.

  • open-menu: Opens the menu

  • close-menu: Closes the menu

Element Properties

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 "white"
property font_color: str | int | list | tuple[L, A] | tuple[R, G, B] | tuple[R, G, B, A]
The color of the font.
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 elements outline. Set to None to use no outline (i.e. the background color).
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_select: Callable[[DropDown, str], Any]
Function to call when an option is selected from the menu. The element and the selected value are passed to the function.
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 closed_icon: mdi:icon
The icon shown at the right hand of the element when the dropdown menu is not open.
Optional, defaults to "mdi:menu-down"
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 fit_text: bool
Adjusts the font size automatically to make it fit. If true, font_size will be used as a minimum allowed font_size.
Optional, defaults to False
property font
The path to the element’s font. If set to a shorthand font, the path will automatically be parsed.
Optional, defaults to "default"
property font_size: str | int | float
The size of the font.
Optional, defaults to "H*0.036"
property margins: tuple[int, int, int, int]
The text margins. Always returns a 4 tuple, but can be set to a single number, or two/three/four item iterable. Same as css margins, so the values are returned as (top,right,bottom,left), and set according to css margins (https://www.w3schools.com/css/css_margin.asp).
Optional, defaults to None
property multiline: bool
Allows the button to try and fit its text over multiple lines. May not work very well with the settings that automatically set the font size.
Optional, defaults to False
property opened_icon: mdi:icon
The icon shown at the right hand of the element when the dropdown menu is open.
Optional, defaults to "mdi:menu-up"
property outline_width: str | int | float
The width of the outline of the background rectangle.
Optional, defaults to 5
property radius: str | int | float
Corner radius of the encapsulating rectangle. Currently only accepts integers.
Optional, defaults to "h*0.2"
property resize: bool | str | int | float
Tracks the font_size and adjusts it to fit. The resize value updates and will be used as a starting point for the next update. If not False, will use this value as a minimum allowed size for any text displayed. Changes the font_size parameter when needed, such that the text size won’t change with every new text. Sizes are not saved upon resets, so finding a good size takes a few changes. The same goes when the element is resized.
Optional, defaults to False
property text_anchor_alignment: tuple[Literal[None, 'l', 'm', 'r', 's'], Literal[None, 'a', 't', 'm', 's', 'b', 'd']]
Alignment of the textAnchor as (horizontal,vertical). Leave (one of) None to determine the anchor from text_x_position or text_y_position respectively. See https://pillow.readthedocs.io/en/stable/handbook/text-anchors.html#text-anchors for possible values, only accepts shorthands.
Optional, defaults to (None, None)
property text_x_position: int | Literal['l', 'm', 'r', 's']
Horizontal alignment of the text. Can be top, bottom or center, a Pillow textanchor (shorthand and longhand), a pssm dimensional string or an integer.
Optional, defaults to "center"
property text_y_position: int | Literal['a', 't', 'm', 's', 'b', 'd']
Vertical alignment of the text. Can be top, bottom or center, a Pillow textanchor (shorthand and longhand), a pssm dimensional string or an integer.
Optional, defaults to "center"
property background_color: str | int | list | tuple[L, A] | tuple[R, G, B] | tuple[R, G, B, A] | None

Optional, defaults to "white"

property font_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_select: Callable[[DropDown, str], Any]

Optional, defaults to None

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

Optional, defaults to None

property closed_icon: mdi:icon

Optional, defaults to "mdi:menu-down"

property feedback_duration: duration

Optional, defaults to 0.75

property fit_text: bool

Optional, defaults to False

property font

Optional, defaults to "default"

property font_size: str | int | float

Optional, defaults to "H*0.036"

property margins: tuple[int, int, int, int]

Optional, defaults to None

property multiline: bool

Optional, defaults to False

property opened_icon: mdi:icon

Optional, defaults to "mdi:menu-up"

property outline_width: str | int | float

Optional, defaults to 5

property radius: str | int | float

Optional, defaults to "h*0.2"

property resize: bool | str | int | float

Optional, defaults to False

property text_anchor_alignment: tuple[Literal[None, 'l', 'm', 'r', 's'], Literal[None, 'a', 't', 'm', 's', 'b', 'd']]

Optional, defaults to (None, None)

property text_x_position: int | Literal['l', 'm', 'r', 's']

Optional, defaults to "center"

property text_y_position: int | Literal['a', 't', 'm', 's', 'b', 'd']

Optional, defaults to "center"

  • background_color, Optional, defaults to "white". Color of the element background.

  • font_color, Optional, defaults to "black". The color of the font

  • outline_color, Optional, defaults to None. Color of the elements 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.

  • on_select, Optional, defaults to None. Function to call when an option is selected from the menu.

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

  • closed_icon, Optional, defaults to "mdi:menu-down". The icon shown at the right hand of the element when the dropdown menu is not open

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

  • fit_text, Optional, defaults to False. Adjusts the font size automatically to make it fit.

  • font, Optional, defaults to "default". The path to the element’s font.

  • font_size, Optional, defaults to "H*0.036". The size of the font

  • margins, Optional, defaults to None. The text margins.

  • multiline, Optional, defaults to False. Allows the button to try and fit its text over multiple lines.

  • opened_icon, Optional, defaults to "mdi:menu-up". The icon shown at the right hand of the element when the dropdown menu is open

  • outline_width, Optional, defaults to 5. The width of the outline of the background rectangle

  • radius, Optional, defaults to "h*0.2". Corner radius of the encapsulating rectangle.

  • resize, Optional, defaults to False. Tracks the font_size and adjusts it to fit. The resize value updates and will be used as a starting point for the next update.

  • text_anchor_alignment, Optional, defaults to (None, None). Alignment of the textAnchor as (horizontal,vertical).

  • text_x_position, Optional, defaults to "center". Horizontal alignment of the text.

  • text_y_position, Optional, defaults to "center". Vertical alignment of the text.

Previous
Counter
Next
Layouts

2024, Slalamander

Made with Sphinx and Shibuya theme.