Skip to content

tree class

A control that allows for selecting items from a hierarchical view of items.

Methods

__init__()

__init__(
    value=None,
    expanded=True,
    multiple=False,
    select_leafs_only=False,
    row_height=None,
    mode=None,
    dropdown=False,
    label=None,
    selection_message=None,
    show_select_all=False,
    filter=False,
    width="360px",
    height=None,
    lov=None,
    adapter=None, # <code>lambda x: str(x)</code>
    type=None, # Type name of the first lov element
    value_by_id=False,
    on_change=None,
    propagate=None, # App config
    active=True,
    id=None,
    properties=None,
    class_name=None,
    hover_text=None,
) -> None

Create a new tree element.

Parameters:

Name Type Description Default
value dynamic(Any)

Bound to the selection value.

None
expanded dynamic(Union[bool, list[str]])

If Boolean and False, only one node can be expanded at one given level. Otherwise this should be set to an array of the node identifiers that need to be expanded.

True
multiple bool

If True, the user can select multiple items by holding the Ctrl key while clicking on items.

False
select_leafs_only bool

If True, the user can only select leaf nodes.

False
row_height str

The height of each row of the tree, in CSS units.

None
mode str

UNDOCUMENTED

None
dropdown bool

UNDOCUMENTED

False
label str

The label associated with the selector when in dropdown mode.

None
selection_message dynamic(str)

The message shown in the selection area of a dropdown selector when at least one element is selected. If None, the message is the list of all the selected elements.

None
show_select_all bool

If True and multiple is True, the selector shows a "Select all option" button.

False
filter bool

If True, this control is combined with a filter input area.

False
width Union[str, int]

The width of the selector, in CSS units.

360px
height Union[str, int]

The height of the selector, in CSS units.

None
lov dict[str, Any]

The list of values. See the section on List of Values for more details.

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.

<code>lambda x: str(x)</code>
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
value_by_id bool

If False, the selection value (in value) is the selected element in lov. If set to True, then value is set to the id of the selected element in lov.

False
on_change Union[str, Callable]

A function or the name of a function that is triggered when the value changes.
The callback function receives the following parameters:

  • state (State): the state instance.
  • var_name (str): the bound variable name.
  • value (Any): the updated value.

None
propagate bool

Determines whether the control's value is automatically reflected in the bound application variable.
The default value is defined at the application configuration level by the propagate configuration option.
If True, any change to the control's value is immediately reflected in the variable.

App config
active dynamic(bool)

Indicates if this element is active.
If False, the element is disabled, and user interaction is not allowed.

True
id str

The identifier assigned to the rendered HTML component.
This can be used in callbacks or to target the element for styling.

None
properties dict[str, Any]

A dictionary of additional properties that can be set to the element.

None
class_name dynamic(str)

A space-separated list of CSS class names to be applied to the generated HTML element.
These classes are added to the default taipy-tree class.

None
hover_text dynamic(str)

The text that is displayed when the user hovers over the element.

None