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,
    label=None,
    mode=None,
    dropdown=False,
    filter=False,
    width="360px",
    height=None,
    lov=None,
    adapter=None, # lambda x: str(x)
    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 Any
dynamic

Bound to the selection value.

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

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 this tree, in CSS units.

None
label str

The label associated with the selector when in dropdown mode.

None
mode str

Define the way the selector is displayed:

  • "radio": as a list of radio buttons
  • "check": as a list of check boxes
  • any other value: a plain list.
None
dropdown bool

If True, the list of items is shown in a dropdown menu.

You cannot use the filter in that situation.

False
filter bool

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

False
width Union[str, int]

The width of this selector, in CSS units.

360px
height Union[str, int]

The height of this 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.

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
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 is updated.
This function is invoked with the following parameters:

  • state (State): the state instance.
  • var_name (str): the variable name.
  • value (Any): the new value.
None
propagate bool

Allows the control's main value to be automatically propagated.
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 bound application variable.

App config
active bool
dynamic

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

True
id str

The identifier that is assigned to the rendered HTML component.

None
properties dict[str, Any]

Bound to a dictionary that contains additional properties for this element.

None
class_name str
dynamic

The list of CSS class names that are associated with the generated HTML Element.
These class names are added to the default taipy-tree class name.

None
hover_text str
dynamic

The information that is displayed when the user hovers over this element.

None