Skip to content

menu class

Shows a left-side menu.

Methods

__init__()

__init__(
    lov=None,
    adapter=None, # lambda x: str(x)
    type=None, # Type name of the first lov element
    label=None,
    inactive_ids=None,
    width="15vw",
    on_action=None,
    active=True,
) -> None

Create a new menu element.

Parameters:

Name Type Description Default

lov

Union[str,list[Union[str,Icon,Any]]]
dynamic

The list of menu option values.

None

adapter

Union[str, Callable]

A function or the name of the function that transforms an element of lov into a tuple(id:str, label:Union[str,Icon]).
The default value is a function that returns the string representation of the lov element.

lambda x: str(x)

type

str

This property is required if lov contains a non-specific type of data (e.g., a dictionary).
Then:

  • value must be of that type
  • lov must be an iterable containing elements of this type
  • The function set to adapter will receive an object of this type.

The default value is the type of the first element in lov.

Type name of the first lov element

label

str

The title of the menu.

None

inactive_ids

Union[str,list[str]]
dynamic

Semicolon (';')-separated list or a list of menu items identifiers that are disabled.

None

width

str

The width of the menu when unfolded, in CSS units.
Note that when running on a mobile device, the property width[active] is used instead.

15vw

on_action

Union[str, Callable]

A function or the name of a function that is triggered when a menu option is selected.

This function is invoked with the following parameters:

  • state (State): the state instance.
  • id (str): the identifier of the button, if it has one.
  • payload (dict): a dictionary containing details about the callback invocation, with the following keys:
    • action: the name of the action that triggered this callback.
    • args: a list where the first element contains the identifier of the selected option.
None

active

bool
dynamic

Indicates if this component is active.
An inactive component allows no user interaction.

True