Skip to main content

TreeViewItem

An item of a TreeView, with optional subitems.

Example:

fluent.TreeViewItem(
"Documents",
leading=fluent.FluentIcons.FOLDER,
items=[fluent.TreeViewItem("Report.docx")],
)

Inherits: Control

Properties

  • content - The label of this item.
  • expanded - Whether the subitems are shown.
  • items - The subitems of this item, shown below it when it is expanded.
  • leading - An icon or control shown before content.
  • selected - Whether this item is selected.

Events

Properties​

contentinstance-attribute​

content: StrOrControl

The label of this item.

expandedclass-attributeinstance-attribute​

expanded: bool = False

Whether the subitems are shown.

Updated when the user expands or collapses this item.

itemsclass-attributeinstance-attribute​

items: list[TreeViewItem] = field(default_factory=list)

The subitems of this item, shown below it when it is expanded.

leadingclass-attributeinstance-attribute​

leading: IconDataOrControl | None = None

An icon or control shown before content.

selectedclass-attributeinstance-attribute​

selected: bool | None = False

Whether this item is selected.

Updated when the user selects items. In MULTIPLE mode, an item with some of its subitems selected is None.

Events​

on_clickclass-attributeinstance-attribute​

on_click: ControlEventHandler[TreeViewItem] | None = None

Called when this item is clicked.

on_expand_changeclass-attributeinstance-attribute​

on_expand_change: (
    ControlEventHandler[TreeViewItem] | None
) = None

Called when the user expands or collapses this item.

expanded holds the new state.