FileBrowserWidget#

class omni.kit.widget.filebrowser.FileBrowserWidget(title: str, **kwargs)#

Bases: object

The basic UI widget for navigating a filesystem as a tree or grid view. The filesystem can either be from your local machine or the Omniverse Nucleus server.

Parameters:

title (str) – Widget title. Default None.

Keyword Arguments:
  • layout (int) – The overall layout of the window, one of: {LAYOUT_SPLIT_PANES, LAYOUT_SINGLE_PANE_SLIM, LAYOUT_SINGLE_PANE_WIDE, LAYOUT_DEFAULT}. Default LAYOUT_SPLIT_PANES.

  • splitter_offset (int) – Position of vertical splitter bar. Default 300.

  • tooltip (bool) – Display tooltips when hovering over items. Default False.

  • allow_multi_selection (bool) – Allow multiple items to be selected at once. Default True.

  • mouse_pressed_fn (Callable) – Function called on mouse press. Function signature: void mouse_pressed_fn(pane: int, button: int, key_mode: int, item: FileBrowserItem, x: float=0, y: float=0)

  • mouse_double_clicked_fn (Callable) – Function called on mouse double click. Function signature: void mouse_double_clicked_fn(pane: int, button: int, key_mode: int, item: FileBrowserItem, x: float=0, y: float=0)

  • selection_changed_fn (Callable) – Function called when selection changed. Function signature: void selection_changed_fn(pane: int, selections: list[FileBrowserItem])

  • drop_fn (Callable) – Function called to handle drag-n-drops. Function signature: void drop_fn(dst_item: FileBrowserItem, src_path: str)

  • filter_fn (Callable) – This user function should return True if the given tree view item is visible, False otherwise. Function signature: bool filter_fn(item: FileBrowserItem)

  • show_grid_view (bool) – If True, initialize the folder view to display icons. Default False.

  • show_recycle_widget (bool) – If True, show recycle view in the left bottom corner. Default False.

  • grid_view_scale (int) – Scales grid view, ranges from 0-5. Default 2.

  • on_toggle_grid_view_fn (Callable) – Callback after toggle grid view is executed. Default None.

  • on_scale_grid_view_fn (Callable) – Callback after scale grid view is executed. Default None.

  • icon_provider (Callable) – This callback provides an icon to replace the default one in the tree view. Signature: str icon_provider(item: FileBrowserItem, expanded: bool).

  • thumbnail_provider (Callable) – This callback returns the path to the item’s thumbnail. If not specified, then a default thumbnail is used. Signature: str thumbnail_provider(item: FileBrowserItem).

  • badges_provider (Callable) – This callback provides the list of badges to layer atop the thumbnail in the grid view. Callback signature: List[str] badges_provider(item: FileBrowserItem)

  • treeview_identifier (str) – widget identifier for treeview, only used by tests.

  • enable_zoombar (bool) – Enables/disables zoombar. Default True.

Methods

__init__(title, **kwargs)

add_model_as_subtree(model[, parent])

Add a new model as the subtree of the tree view root model or the given parent item.

clear_item_alert(item)

Clear the alert of the given item.

create_grouping_item(name, path[, parent])

Create a folder item at the given path and add it as child to the tree view root model or the given parent item.

create_treeview_model(name, drop_fn, filter_fn)

Create the model for treeview.

delete_child(item[, parent])

Delete an item from the tree view root model or the given parent item.

delete_child_by_name(item_name[, parent])

Delete an item from the tree view root model or the given parent item.

destroy()

Destructor.

get_root([pane])

Get the root item of the treeview by pane.

get_selected_item([pane])

Return last of selected item from the specified pane.

get_selections([pane])

Return list of selected items from the specified pane.

hide_notification()

Hide the notification frame.

link_views(src_widget)

Link this widget to the given widget, i.e. the 2 widgets will therafter display the same models but not necessarily share the same view.

refresh_ui([item, listview_only])

Redraw the subtree rooted at the given item.

scale_grid_view(scale)

Set the scale of item inside grid view.

select_and_center(selection[, pane])

Select and centers the tree view on the given item, expanding the tree if needed.

set_expanded(item, expanded[, recursive])

Set the expansion state of the given item.

set_item_alert(item, alert_level, msg)

Set the alert message of the given item.

set_item_error(item, msg)

Set the error message of the given item.

set_item_info(item, msg)

Set the info message of the given item.

set_item_warning(item, msg)

Set the warning message of the given item.

set_selections(selections[, pane])

Selected given items in given pane.

show_model(model)

Show the given model.

show_notification()

Show the notification frame.

toggle_grid_view(show_grid_view)

Toggle on/of grid view.

Attributes

show_grid_view

Return True if grid view is visible.

show_udim_sequence

Return True if the list model has UDIM sequence visible.

__init__(title: str, **kwargs)#
add_model_as_subtree(
model: FileBrowserModel,
parent: FileBrowserItem = None,
)#

Add a new model as the subtree of the tree view root model or the given parent item.

Parameters:
  • model (FileBrowserModel) – the model to add.

  • parent (FileBrowserItem) – If set, add the model as a child to this item instead of the tree view root model.

clear_item_alert(
item: FileBrowserItem,
)#

Clear the alert of the given item.

Parameters:

item (FileBrowserItem) – Item to clear the alert.

create_grouping_item(
name: str,
path: str,
parent: FileBrowserItem = None,
) FileBrowserItem#

Create a folder item at the given path and add it as child to the tree view root model or the given parent item.

Parameters:
  • name (str) – name of the item.

  • path (str) – path of the item.

  • parent (str) – If set, add the item as a child to this item instead of the tree view root model.

create_treeview_model(
name: str,
drop_fn: Callable,
filter_fn: Callable,
) FileBrowserModel#

Create the model for treeview. Override this method to create a custom model for treeview.

Parameters:
  • name (str) – Name of the model.

  • drop_fn (Callable) – Drop function.

  • filter_fn (Callable) – Filter function.

Returns:

The model for treeview.

Return type:

FileBrowserModel

delete_child(
item: FileBrowserItem,
parent: FileBrowserItem = None,
)#

Delete an item from the tree view root model or the given parent item.

Parameters:
  • model (FileBrowserModel) – the item to remove.

  • parent (FileBrowserItem) – If set, remove the item from this item instead of the tree view root model.

delete_child_by_name(
item_name: str,
parent: FileBrowserItem = None,
)#

Delete an item from the tree view root model or the given parent item.

Parameters:
  • item_name (str) – the item name to remove.

  • parent (FileBrowserItem) – If set, remove the item from this item instead of the tree view root model.

destroy()#

Destructor. Called by extension before destroying this object. It doesn’t happen automatically. Without this hot reloading doesn’t work.

get_root(
pane: int = None,
) FileBrowserItem#

Get the root item of the treeview by pane.

get_selected_item(
pane: int = 1,
) FileBrowserItem#

Return last of selected item from the specified pane.

Parameters:

pane (int) – One of TREEVIEW_PANE, LISTVIEW_PANE. Returns the union if None is specified.

Returns:

`FileBrowserItem` or None

get_selections(
pane: int = 1,
) List[FileBrowserItem]#

Return list of selected items from the specified pane.

Parameters:

pane (int) – One of TREEVIEW_PANE, LISTVIEW_PANE. Returns the union if None is specified.

Returns:

list[FileBrowserItem]

hide_notification()#

Hide the notification frame.

Link this widget to the given widget, i.e. the 2 widgets will therafter display the same models but not necessarily share the same view.

Parameters:

src_widget (FilePickerWidget) – The source widget.

refresh_ui(
item: FileBrowserItem = None,
listview_only: bool = False,
)#

Redraw the subtree rooted at the given item. If item is None, then redraws entire tree.

Parameters:

item (FileBrowserItem) – Root of subtree to redraw. Default None, i.e. root.

scale_grid_view(scale: float)#

Set the scale of item inside grid view.

select_and_center(
selection: FileBrowserItem,
pane: int = 1,
)#

Select and centers the tree view on the given item, expanding the tree if needed.

Parameters:
  • selection (FileBrowserItem) – The selected item.

  • pane (int) – One of TREEVIEW_PANE, LISTVIEW_PANE.

set_expanded(
item: FileBrowserItem,
expanded: bool,
recursive: bool = False,
)#

Set the expansion state of the given item.

Parameters:
  • item (FileBrowserItem) – The item to effect.

  • expanded (bool) – True to expand, False to collapse.

  • recursive (bool) – Apply state recursively to descendent nodes. Default False.

set_item_alert(
item: FileBrowserItem,
alert_level: int,
msg: str,
)#

Set the alert message of the given item.

Parameters:
  • item (FileBrowserItem) – Item to set alert.

  • alert_level (int) – level of alert.

  • msg (str) – message to alert.

set_item_error(
item: FileBrowserItem,
msg: str,
)#

Set the error message of the given item.

Parameters:
  • item (FileBrowserItem) – Item to set alert.

  • alert_level (int) – level of alert.

  • msg (str) – message to alert.

set_item_info(
item: FileBrowserItem,
msg: str,
)#

Set the info message of the given item.

Parameters:
  • item (FileBrowserItem) – Item to set alert.

  • alert_level (int) – level of alert.

  • msg (str) – message to alert.

set_item_warning(
item: FileBrowserItem,
msg: str,
)#

Set the warning message of the given item.

Parameters:
  • item (FileBrowserItem) – Item to set alert.

  • alert_level (int) – level of alert.

  • msg (str) – message to alert.

set_selections(
selections: List[FileBrowserItem],
pane: int = 1,
)#

Selected given items in given pane.

Parameters:
  • selections (list[FileBrowserItem]) – list of selections.

  • pane (int) – One of TREEVIEW_PANE, LISTVIEW_PANE, or None for both. Default None.

show_model(
model: FileBrowserModel,
)#

Show the given model.

show_notification()#

Show the notification frame.

toggle_grid_view(show_grid_view: bool)#

Toggle on/of grid view.

property show_grid_view#

Return True if grid view is visible.

property show_udim_sequence#

Return True if the list model has UDIM sequence visible.