FileBrowserModel

class omni.kit.widget.filebrowser.model.FileBrowserModel(name: Optional[str] = None, root_path: str = '', **kwargs)

Bases: AbstractItemModel

Base class for the Filebrowser view Model. Should be sub-classed to implement specific filesystem behavior.

Parameters

name (str) – Name of root item. If None given, then create an initally empty model.

Keyword Arguments
  • drop_fn (Callable) – Function called to handle drag-n-drops. Function signature: void drop_fn(dst_item: FileBrowserItem`, src_item: :obj:`FileBrowserItem)

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

  • sort_by_field (str) – Name of column by which to sort items in the same folder. Default “name”.

  • sort_ascending (bool) – Sort in ascending order. Default True.

  • timeout (float) – Timeout when updating item asynchronously.

Methods

__init__(self)

Constructs AbstractItemModel.

auto_refresh_item(item[, throttle_frames])

Watch the given folder and updates the children list as soon as its contents are changed.

copy_presets(model)

Reset our fields to default arguments from the given model.

destroy()

Destructor.

drop(dst_item, source)

Invoke user-supplied function to handle dropping source onto destination item.

drop_accepted(dst_item, src_item)

Reimplemented from AbstractItemModel.

filter_items(items)

Return the items fitlered with the filter function set.

get_drag_mime_data(item)

Return Multipurpose Internet Mail Extensions (MIME) data for be able to drop this item somewhere

get_item_children(item)

Return the list of items that are nested to the given parent item.

get_item_value_model(item, index)

Get the value model associated with this item.

get_item_value_model_count(item)

Return the number of columns this model item contains.

on_list_change_event(item, result, event, entry)

Process change events for the given folder.

set_filter_fn(filter_fn)

Set the handler that would return True if the given Filebrowser view item is visible, False otherwise.

sync_up_item_changes(item)

Scan given folder for missed changes; processes any changes found.

Attributes

builtin_column_count

Return the number of available columns without tag delegates

drag_mime_data

Return the string with the drag and drop payload.

root

Get/set the root item of this model.

show_udim_sequence

Show the UDIM sequence.

single_column

The panel on the left side works in one-column mode

sort_ascending

Get/set the sort ascending state.

sort_by_field

Get/set the sort-by field name.

__init__(self: omni.ui._ui.AbstractItemModel) None

Constructs AbstractItemModel.

`kwargsdict`

See below

### Keyword Arguments:

auto_refresh_item(item: FileBrowserItem, throttle_frames: int = 4)

Watch the given folder and updates the children list as soon as its contents are changed.

Parameters
  • item (FileBrowserItem) – The folder item to watch.

  • throttle_frames – Number of frames to throttle the UI refresh.

copy_presets(model: FileBrowserModel)

Reset our fields to default arguments from the given model.

destroy()

Destructor.

drop(dst_item: FileBrowserItem, source: Union[str, FileBrowserItem])

Invoke user-supplied function to handle dropping source onto destination item.

Parameters
drop_accepted(dst_item: FileBrowserItem, src_item: FileBrowserItem) bool

Reimplemented from AbstractItemModel. Called to highlight target when drag and drop. Returns True if destination item is able to accept a drop. This function can be overriden to implement a different behavior.

Parameters
Returns

bool

filter_items(items: List[FileBrowserItem]) List[FileBrowserItem]

Return the items fitlered with the filter function set.

get_drag_mime_data(item: FileBrowserItem)

Return Multipurpose Internet Mail Extensions (MIME) data for be able to drop this item somewhere

get_item_children(item: FileBrowserItem) [FileBrowserItem]

Return the list of items that are nested to the given parent item.

Parameters

item (FileBrowserItem) – Parent item.

Returns

list[FileBrowserItem]

get_item_value_model(item: FileBrowserItem, index: int) object

Get the value model associated with this item.

Parameters

item (FileBrowserItem) – The item in question.

Returns

AbstractValueModel

get_item_value_model_count(item: FileBrowserItem) int

Return the number of columns this model item contains.

Parameters

item (FileBrowserItem) – The item in question.

Returns

int

on_list_change_event(item: FileBrowserItem, result: Result, event: ListEvent, entry: ListEntry, throttle_frames: int = 4)

Process change events for the given folder.

Parameters
  • item (FileBrowserItem) – The folder item.

  • result (omni.client.Result) – Set by omni.client upon listing the folder.

  • event (omni.client.ListEvent) – Event type.

  • throttle_frames – Number of frames to throttle the UI refresh.

set_filter_fn(filter_fn: Callable[[str], bool])

Set the handler that would return True if the given Filebrowser view item is visible, False otherwise. Function signature: bool filter_fn(item: FileBrowserItem)

sync_up_item_changes(item: FileBrowserItem)

Scan given folder for missed changes; processes any changes found.

Parameters

item (FileBrowserItem) – The folder item to watch.

property builtin_column_count

Return the number of available columns without tag delegates

property drag_mime_data

Return the string with the drag and drop payload.

property root: FileBrowserItem

Get/set the root item of this model.

Type

FileBrowserItem

property show_udim_sequence

Show the UDIM sequence.

property single_column

The panel on the left side works in one-column mode

property sort_ascending: bool

Get/set the sort ascending state.

Type

FileBrowserItem

property sort_by_field: str

Get/set the sort-by field name.

Type

FileBrowserItem