TreeView
- class omni.ui.TreeView
Bases:
Widget
,ItemModelHelper
TreeView is a widget that presents a hierarchical view of information. Each item can have a number of subitems. An indentation often visualizes this in a list. An item can be expanded to reveal subitems, if any exist, and collapsed to hide subitems. TreeView can be used in file manager applications, where it allows the user to navigate the file system directories. They are also used to present hierarchical data, such as the scene object hierarchy. TreeView uses a model/view pattern to manage the relationship between data and the way it is presented. The separation of functionality gives developers greater flexibility to customize the presentation of items and provides a standard interface to allow a wide range of data sources to be used with other widgets. TreeView is responsible for the presentation of model data to the user and processing user input. To allow some flexibility in the way the data is presented, the creation of the sub-widgets is performed by the delegate. It provides the ability to customize any sub-item of TreeView.
Methods
__init__
(*args, **kwargs)Overloaded function.
call_hover_changed_fn
(self, arg0, arg1)Set the callback that is called when the item hover status is changed.
call_selection_changed_fn
(self, arg0)Set the callback that is called when the selection is changed.
clear_selection
(self)Deselects all selected items.
dirty_widgets
(self)When called, it will make the delegate to regenerate all visible widgets the next frame.
extend_selection
(self, item)Extends the current selection selecting all the items between currently selected nodes and the given item.
has_hover_changed_fn
(self)Set the callback that is called when the item hover status is changed.
has_selection_changed_fn
(self)Set the callback that is called when the selection is changed.
is_expanded
(self, item)Returns true if the given item is expanded.
set_expanded
(self, item, expanded, recursive)Sets the given item expanded or collapsed.
set_hover_changed_fn
(self, fn)Set the callback that is called when the item hover status is changed.
set_selection_changed_fn
(self, fn)Set the callback that is called when the selection is changed.
toggle_selection
(self, item)Switches the selection state of the given item.
Attributes
Widths of the columns.
When true, the columns can be resized with the mouse.
When true, the tree nodes can be dropped between items.
This flag allows to prevent expanding when the user clicks the plus icon.
This property holds if the header is shown or not.
When true, the tree nodes are never destroyed even if they are disappeared from the model.
Expand all the nodes and keep them expanded regardless their state.
Minimum widths of the columns.
The expanded state of the root item.
This property holds if the root is shown.
Set current selection.
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: omni.ui._ui.TreeView, **kwargs) -> None
Create TreeView with default model.
__init__(self: omni.ui._ui.TreeView, arg0: omni.ui._ui.AbstractItemModel, **kwargs) -> None
Create TreeView with the given model.
### Arguments:
- `model :`
The given model.
- `kwargsdict`
See below
### Keyword Arguments:
- `delegate`
The Item delegate that generates a widget per item.
- `header_visible`
This property holds if the header is shown or not.
- `selection`
Set current selection.
- `expand_on_branch_click`
This flag allows to prevent expanding when the user clicks the plus icon. It’s used in the case the user wants to control how the items expanded or collapsed.
- `keep_alive`
When true, the tree nodes are never destroyed even if they are disappeared from the model. It’s useul for the temporary filtering if it’s necessary to display thousands of nodes.
- `keep_expanded`
Expand all the nodes and keep them expanded regardless their state.
- `drop_between_items`
When true, the tree nodes can be dropped between items.
- `column_widths`
Widths of the columns. If not set, the width is Fraction(1).
- `min_column_widths`
Minimum widths of the columns. If not set, the width is Pixel(0).
- `columns_resizable`
When true, the columns can be resized with the mouse.
- `selection_changed_fn`
Set the callback that is called when the selection is changed.
- `root_expanded`
The expanded state of the root item. Changing this flag doesn’t make the children repopulated.
- `widthui.Length`
This property holds the width of the widget relative to its parent. Do not use this function to find the width of a screen.
- `heightui.Length`
This property holds the height of the widget relative to its parent. Do not use this function to find the height of a screen.
- `namestr`
The name of the widget that user can set.
- `style_type_name_overridestr`
By default, we use typeName to look up the style. But sometimes it’s necessary to use a custom name. For example, when a widget is a part of another widget. (Label is a part of Button) This property can override the name to use in style.
- `identifierstr`
An optional identifier of the widget we can use to refer to it in queries.
- `visiblebool`
This property holds whether the widget is visible.
- `visibleMinfloat`
If the current zoom factor and DPI is less than this value, the widget is not visible.
- `visibleMaxfloat`
If the current zoom factor and DPI is bigger than this value, the widget is not visible.
- `tooltipstr`
Set a basic tooltip for the widget, this will simply be a Label, it will follow the Tooltip style
- `tooltip_fnCallable`
Set dynamic tooltip that will be created dynamiclly the first time it is needed. the function is called inside a ui.Frame scope that the widget will be parented correctly.
- `tooltip_offset_xfloat`
Set the X tooltip offset in points. In a normal state, the tooltip position is linked to the mouse position. If the tooltip offset is non zero, the top left corner of the tooltip is linked to the top left corner of the widget, and this property defines the relative position the tooltip should be shown.
- `tooltip_offset_yfloat`
Set the Y tooltip offset in points. In a normal state, the tooltip position is linked to the mouse position. If the tooltip offset is non zero, the top left corner of the tooltip is linked to the top left corner of the widget, and this property defines the relative position the tooltip should be shown.
- `enabledbool`
This property holds whether the widget is enabled. In general an enabled widget handles keyboard and mouse events; a disabled widget does not. And widgets display themselves differently when they are disabled.
- `selectedbool`
This property holds a flag that specifies the widget has to use eSelected state of the style.
- `checkedbool`
This property holds a flag that specifies the widget has to use eChecked state of the style. It’s on the Widget level because the button can have sub-widgets that are also should be checked.
- `draggingbool`
This property holds if the widget is being dragged.
- `opaque_for_mouse_eventsbool`
If the widgets has callback functions it will by default not capture the events if it is the top most widget and setup this option to true, so they don’t get routed to the child widgets either
- `skip_draw_when_clippedbool`
The flag that specifies if it’s necessary to bypass the whole draw cycle if the bounding box is clipped with a scrolling frame. It’s needed to avoid the limitation of 65535 primitives in a single draw list.
- `mouse_moved_fnCallable`
Sets the function that will be called when the user moves the mouse inside the widget. Mouse move events only occur if a mouse button is pressed while the mouse is being moved. void onMouseMoved(float x, float y, int32_t modifier)
- `mouse_pressed_fnCallable`
Sets the function that will be called when the user presses the mouse button inside the widget. The function should be like this: void onMousePressed(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier) Where ‘button’ is the number of the mouse button pressed. ‘modifier’ is the flag for the keyboard modifier key.
- `mouse_released_fnCallable`
Sets the function that will be called when the user releases the mouse button if this button was pressed inside the widget. void onMouseReleased(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier)
- `mouse_double_clicked_fnCallable`
Sets the function that will be called when the user presses the mouse button twice inside the widget. The function specification is the same as in setMousePressedFn. void onMouseDoubleClicked(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier)
- `mouse_wheel_fnCallable`
Sets the function that will be called when the user uses mouse wheel on the focused window. The function specification is the same as in setMousePressedFn. void onMouseWheel(float x, float y, carb::input::KeyboardModifierFlags modifier)
- `mouse_hovered_fnCallable`
Sets the function that will be called when the user use mouse enter/leave on the focused window. function specification is the same as in setMouseHovedFn. void onMouseHovered(bool hovered)
- `drag_fnCallable`
Specify that this Widget is draggable, and set the callback that is attached to the drag operation.
- `accept_drop_fnCallable`
Specify that this Widget can accept specific drops and set the callback that is called to check if the drop can be accepted.
- `drop_fnCallable`
Specify that this Widget accepts drops and set the callback to the drop operation.
- `computed_content_size_changed_fnCallable`
Called when the size of the widget is changed.
- call_hover_changed_fn(self: omni.ui._ui.TreeView, arg0: omni.ui._ui.AbstractItem, arg1: bool) None
Set the callback that is called when the item hover status is changed.
- call_selection_changed_fn(self: omni.ui._ui.TreeView, arg0: List[omni.ui._ui.AbstractItem]) None
Set the callback that is called when the selection is changed.
- clear_selection(self: omni.ui._ui.TreeView) None
Deselects all selected items.
- dirty_widgets(self: omni.ui._ui.TreeView) None
When called, it will make the delegate to regenerate all visible widgets the next frame.
- extend_selection(self: omni.ui._ui.TreeView, item: omni.ui._ui.AbstractItem) None
Extends the current selection selecting all the items between currently selected nodes and the given item. It’s when user does shift+click.
- has_hover_changed_fn(self: omni.ui._ui.TreeView) bool
Set the callback that is called when the item hover status is changed.
- has_selection_changed_fn(self: omni.ui._ui.TreeView) bool
Set the callback that is called when the selection is changed.
- is_expanded(self: omni.ui._ui.TreeView, item: omni.ui._ui.AbstractItem) bool
Returns true if the given item is expanded.
- set_expanded(self: omni.ui._ui.TreeView, item: omni.ui._ui.AbstractItem, expanded: bool, recursive: bool) None
Sets the given item expanded or collapsed.
### Arguments:
- `item :`
The item to expand or collapse.
- `expanded :`
True if it’s necessary to expand, false to collapse.
- `recursive :`
True if it’s necessary to expand children.
- set_hover_changed_fn(self: omni.ui._ui.TreeView, fn: Callable[[omni.ui._ui.AbstractItem, bool], None]) None
Set the callback that is called when the item hover status is changed.
- set_selection_changed_fn(self: omni.ui._ui.TreeView, fn: Callable[[List[omni.ui._ui.AbstractItem]], None]) None
Set the callback that is called when the selection is changed.
- toggle_selection(self: omni.ui._ui.TreeView, item: omni.ui._ui.AbstractItem) None
Switches the selection state of the given item.
- property column_widths
Widths of the columns. If not set, the width is Fraction(1).
- property columns_resizable
When true, the columns can be resized with the mouse.
- property drop_between_items
When true, the tree nodes can be dropped between items.
- property expand_on_branch_click
This flag allows to prevent expanding when the user clicks the plus icon. It’s used in the case the user wants to control how the items expanded or collapsed.
- property header_visible
This property holds if the header is shown or not.
- property keep_alive
When true, the tree nodes are never destroyed even if they are disappeared from the model. It’s useul for the temporary filtering if it’s necessary to display thousands of nodes.
- property keep_expanded
Expand all the nodes and keep them expanded regardless their state.
- property min_column_widths
Minimum widths of the columns. If not set, the width is Pixel(0).
- property root_expanded
The expanded state of the root item. Changing this flag doesn’t make the children repopulated.
- property root_visible
This property holds if the root is shown. It can be used to make a single level tree appear like a simple list.
- property selection
Set current selection.