FileBrowserItem#

class omni.kit.widget.filebrowser.FileBrowserItem(
path: str,
fields: FileBrowserItemFields,
is_folder: bool = False,
is_deleted: bool = False,
)#

Bases: AbstractItem

Base class for the Filebrowser view Item. Should be sub-classed to implement specific filesystem behavior. The Constructor should not be called directly. Instead there are factory methods available for creating instances when needed.

Parameters:
  • path (str) – Path of the item.

  • fields (FileBrowserItemFields) – Fields of the item.

  • is_folder (bool) – Set to True if the item is a folder.

  • is_deleted (bool) – Set to True if the item is deleted.

Methods

__init__(self)

add_child(item)

Add item as child.

datetime_as_string(value)

Convert datatime to string.

del_child(item_name)

Delete child item by name.

get_custom_thumbnails_for_folder_async()

Return the thumbnail dictionary for this (folder) item.

get_subitem_model(index)

Return ith column of this item.

has_mouse_pressed_fn()

Check if the item has a mouse pressed callback assigned.

mouse_pressed_fn()

Mouse pressed callback.

on_list_change_event(event, entry)

Virtual method to be implemented by sub-class.

on_populated_async([result, children, callback])

async callback after finish populating the item.

populate_async([callback_async, timeout])

Populate current item asynchronously if not already.

populate_children_async()

populate_with_callback(callback[, timeout])

Populate this item if not already populated.

size_as_string(value)

Convert data size in bytes to a human readable string.

update_permissions(new_permissions)

Update item's permissions.

Attributes

alert

Get/set alert level and message.

children

Children of this item.

context_menu

Optionally provide a context menu to be show when this item is right-clicked.

enable_sorting

True if item's children are sortable.

expandable

whether this FileBrowserItem is expandable.

fields

A subset of the item's stats stored as a string tuple.

hideable

whether this FileBrowserItem is hideable.

icon

Get/set path to icon file.

is_deleted

True if this item is a deleted folder/file.

is_folder

True if this item is a folder.

is_udim_file

Get/Set item udim_file state.

item_changed

True if this item is has been restore/delete aready.

models

The columns of this item.

name

Item name.

parent

Parent of this item.

path

Full path name.

populated

Get/Set item populated state.

readable

True if the item is readable.

writeable

True if the item is writeable.

__init__(self: omni.ui._ui.AbstractItem) None#
add_child(
item: object,
) FileBrowserItem | None#

Add item as child.

Parameters:

item (FileBrowserItem) – Child item.

Returns:

The added item.

Return type:

FileBrowserItem

static datetime_as_string(value: datetime) str#

Convert datatime to string.

del_child(
item_name: str,
) FileBrowserItem | None#

Delete child item by name.

Parameters:

item_name (str) – Name of child item.

Returns:

The deleted item.

Return type:

FileBrowserItem

async get_custom_thumbnails_for_folder_async() Dict#

Return the thumbnail dictionary for this (folder) item.

Returns:

With children url’s as keys, and url’s to thumbnail files as values.

Return type:

Dict

get_subitem_model(index: int) object#

Return ith column of this item.

Returns:

AbstractValueModel

has_mouse_pressed_fn()#

Check if the item has a mouse pressed callback assigned.

mouse_pressed_fn()#

Mouse pressed callback.

on_list_change_event(
event: ListEvent,
entry: ListEntry,
) bool#

Virtual method to be implemented by sub-class. When called with a ListEvent, should update this item’s children list with the corresponding ListEntry.

Parameters:
  • event (omni.client.ListEvent) – One of of {UNKNOWN, CREATED, UPDATED, DELETED, METADATA, LOCKED, UNLOCKED}.

  • entry (omni.client.ListEntry) – Updated entry as defined by omni.client.

async on_populated_async(
result=None,
children: Dict[str, FileBrowserItem] | None = None,
callback: Callable[[Dict[str, FileBrowserItem]], None] | None = None,
)#

async callback after finish populating the item.

Parameters:
  • result (Any) – result from populate async.

  • children (Dict[str, FileBrowserItem]) – dictionary of children items to pass to the callback.

  • callback (Callable) – function to call.Function signature: callback(result: Any, children: Dict[str, FileBrowserItem]) -> None

async populate_async(
callback_async: Callable = None,
timeout: float = 10.0,
) Any#

Populate current item asynchronously if not already. Override this method to customize for specific file systems.

Parameters:
  • callback_async (Callable) – Function signature is void callback(result, children: Dict[str, FileBrowserItem]), where result is an Exception type upon error.

  • timeout (float) – Time out duration on failed server connections. Default 10.0.

Returns:

Result of executing callback.

Return type:

Any

populate_with_callback(
callback: Callable,
timeout: float = 10.0,
)#

Populate this item if not already populated. When done, executes callback.

Parameters:
  • callback (Callable) – Function signature is void callback(children: [FileBrowserItem]).

  • timeout (float) – Time out duration on failed server connections. Default 10.0.

static size_as_string(value: int) str#

Convert data size in bytes to a human readable string.

update_permissions(
new_permissions: AccessFlags,
)#

Update item’s permissions.

Parameters:

new_permissions( – obj:’omni.client.AccessFlags’): New permissions to this item.

property alert: Tuple[int, str]#

Get/set alert level and message.

property children: Dict[str, FileBrowserItem]#

Children of this item. Does not populate the item if not already populated.

Type:

dict[FileBrowserItem]

property context_menu: 'BaseContextMenu' | None#

Optionally provide a context menu to be show when this item is right-clicked.

property enable_sorting: bool#

True if item’s children are sortable.

Type:

bool

property expandable: bool#

whether this FileBrowserItem is expandable. Override to change behavior

property fields: FileBrowserItemFields#

A subset of the item’s stats stored as a string tuple.

Type:

FileBrowserItemFields

property hideable: bool#

whether this FileBrowserItem is hideable. Override to change behavior

property icon: str#

Get/set path to icon file.

Type:

str

property is_deleted: bool#

True if this item is a deleted folder/file.

Type:

bool

property is_folder: bool#

True if this item is a folder.

Type:

bool

property is_udim_file: bool#

Get/Set item udim_file state.

Type:

bool

property item_changed: bool#

True if this item is has been restore/delete aready.

Type:

bool

property models: Tuple#

The columns of this item.

Type:

Tuple[ui.AbstractValueModel]

property name: str#

Item name.

Type:

str

property parent: object#

Parent of this item.

Type:

FileBrowserItem

property path: str#

Full path name.

Type:

str

property populated: bool#

Get/Set item populated state.

Type:

bool

property readable: bool#

True if the item is readable.

property writeable: bool#

True if the item is writeable.