omni.kit.window.filepicker

Kit Filepicker Dialog and embeddable Widget.

This Kit extension provides both a popup dialog as well as an embeddable widget that you can add to your code for browsing the filesystem. Incorporates BrowserBarWidget and FileBrowserWidget into a general-purpose utility. The filesystem can either be from your local machine or the Omniverse server.

Example

With just a few lines of code, you can create a ready-made dialog window. Then, customize it by setting any number of attributes.

filepicker = FilePickerDialog(

“my-filepicker”, apply_button_label=”Open”, click_apply_handler=on_click_open, click_cancel_handler=on_click_cancel )

filepicker.show()

class omni.kit.window.filepicker.FilePickerDialog(title: str, **kwargs)

Bases: object

A popup window for browsing the filesystem and taking action on a selected file. Includes a browser bar for keyboard input with auto-completion for navigation of the tree view. For similar but different options, see also FilePickerWidget and FilePickerView.

Parameters

title (str) – Window title. Default None.

Keyword Arguments
  • width (int) – Window width. Default 1200.

  • height (int) – Window height. Default 600.

  • click_apply_handler (func) – Function that will be called when the user accepts the selection. Function signature: void apply_handler(file_name: str, dir_name: str).

  • click_cancel_handler (func) – Function that will be called when the user clicks the cancel button. Function signature: void cancel_handler(file_name: str, dir_name: str).

  • other – Additional args listed for FilePickerWidget

add_connections(connections: dict)

Adds specified server connections to the browser.

Parameters

connections (dict) – A dictionary of name, path pairs. For example: {“C:”: “C:”, “ov-content”: “omniverse://ov-content”}. Paths to Omniverse servers should be prefixed with “omniverse://”.

property current_filter_option

Index of current filter option, range 0 .. num_filter_options.

Type

int

destroy()

Destructor.

get_current_directory()str

Returns the current directory from the browser bar.

Returns

The system path, which may be different from the displayed path.

Return type

str

get_current_selections(pane: int = 2) → List[str]

Returns current selected as list of system path names.

Parameters

pane (int) – Specifies pane to retrieve selections from, one of {TREEVIEW_PANE = 1, LISTVIEW_PANE = 2, BOTH = None}. Default LISTVIEW_PANE.

Returns

List of system paths (which may be different from displayed paths, e.g. bookmarks)

Return type

[str]

get_filename()str
Returns

Currently selected filename.

Return type

str

hide()

Hides this dialog. Automatically called when “Cancel” buttons is clicked.

navigate_to(path: str)

Navigates to a path, i.e. the path’s parent directory will be expanded and leaf selected.

Parameters

path (str) – The path to navigate to.

refresh_current_directory()

Refreshes the current directory set in the browser bar.

set_current_directory(path: str)

Procedurally sets the current directory path.

Parameters

path (str) – The full path name of the folder, e.g. “omniverse://ov-content/Users/me.

Raises

RuntimeWarning – If path doesn’t exist or is unreachable.

set_filename(filename: str)

Sets the filename in the file bar, at bottom of the dialog.

Parameters

filename (str) – The filename only (and not the fullpath), e.g. “myfile.usd”.

show(path: Optional[str] = None)

Shows this dialog. Currently pops up atop all other windows but is not completely modal, i.e. does not take over input focus.

Parameters

path (str) – If optional path is specified, then navigates to it upon startup.

toggle_bookmark_from_path(name: str, path: str, is_bookmark: bool)

Adds/deletes the given bookmark with the specified path. If deleting, then the path argument is optional.

Parameters
  • name (str) – Name to call the bookmark or existing name if delete.

  • path (str) – Path to the bookmark.

  • is_bookmark (bool) – True to add, False to delete.

class omni.kit.window.filepicker.FilePickerWidget(title: str, **kwargs)

Bases: object

An embeddable UI widget for browsing the filesystem and taking action on a selected file. Includes a browser bar for keyboard input with auto-completion for navigation of the tree view. For similar but different options, see also FilePickerDialog and FilePickerView.

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.

  • current_directory (str) – View is set to display this directory. Default None.

  • current_filename (str) – Filename is set to this value. Default None.

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

  • show_grid_view (bool) – Displays grid view in the intial layout. Default True.

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

  • show_only_collections ([str]) – List of collections to display, any combination of [“bookmarks”, “omniverse”, “my-computer”]. If None, then all are displayed. Default None.

  • allow_multi_selection (bool) – Allows multiple selections. Default False.

  • click_apply_handler (func) – Function that will be called when the user accepts the selection. Function signature: void apply_handler(file_name: str, dir_name: str).

  • click_cancel_handler (func) – Function that will be called when the user clicks the cancel button. Function signature: void cancel_handler(file_name: str, dir_name: str).

  • apply_button_label (str) – Alternative label for the apply button. Default “Okay”.

  • enable_file_bar (bool) – Enables/disables file bar. Default True.

  • enable_filename_input (bool) – Enables/disables filename input. Default True.

  • item_filter_options ([str]) – A list of filter options to determine which files should be listed. For example: [‘usd’, ‘wav’]. Default None.

  • item_filter_fn (func) – This user function should return True if the given tree view item is visible, False otherwise. To base the decision on which filter option is currently chosen, use the attribute filepicker.current_filter_option. Function signature: bool item_filter_fn(item: FileBrowserItem)

  • error_handler (func) – This function is called with error messages when appropriate. It provides the calling app a way to display errors on top of writing them to the console window. Function signature: void error_handler(message: str).

  • show_real_path (bool) – Browser bar display system paths only, no aliased paths. Default True.

  • enable_versioning_pane (bool) – OBSOLETE. Use enable_checkpoints instead.

  • enable_checkoints (bool) – Whether the checkoints, a.k.a. versioning pane should be displayed. Default False.

  • options_pane_build_fn (Callable[[List[FileBrowserItem]], bool]) – OBSOLETE, add options in a detail frame instead.

  • options_pane_width (Union[int, omni.ui.Percent]) – OBSOLETE.

  • selection_changed_fn (Callable[[List[FileBrowserItem]], None]) – Selections has changed.

property api

Provides API methods to this widget.

Type

FilePickerAPI

property current_filter_option

Index of current filter option, range 0 .. num_filter_options.

Type

int

destroy()

Destructor.

get_selected_filename_and_directory() → Tuple[str, str]

Get the current directory and filename that has been selected or entered into the filename field

class omni.kit.window.filepicker.FilePickerView(title: str, **kwargs)

Bases: object

An embeddable UI component for browsing the filesystem. This widget is more full-functioned than FileBrowserWidget but less so than FilePickerWidget. More specifically, this is one of the 3 sub-components of its namesake FilePickerWidget. The difference is it doesn’t have the Browser Bar (at top) or the File Bar (at bottom). This gives users the flexibility to substitute in other surrounding components instead.

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.

  • show_grid_view (bool) – Display grid view in the intial layout. Default True.

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

  • show_only_collections (list[str]) – List of collections to display, any combination of [“bookmarks”, “omniverse”, “my-computer”]. If None, then all are displayed. Default None.

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

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

  • mouse_pressed_fn (func) – Function called on mouse press. Function signature: void mouse_pressed_fn(pane: int, button: int, key_mode: int, item: FileBrowserItem)

  • mouse_double_clicked_fn (func) – Function called on mouse double click. Function signature: void mouse_double_clicked_fn(pane: int, button: int, key_mode: int, item: FileBrowserItem)

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

  • drop_handler (func) – Function called to handle drag-n-drops. Function signature: void drop_fn(dst_item: FileBrowserItem, src_paths: [str])

  • add_server_post_handler (func) – This handler is called whenever a server connection is added. A primary use of this callback is to update settings files or similar bookkeeping. Function signature: void add_server_post_handler(name: str, path: str).

  • delete_server_post_handler (func) – This handler is called whenever a server connection is deleted. A primary use of this callback is to update settings files or similar bookkeeping. Function signature: void delete_server_post_handler(name: str, path: str).

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

  • thumbnail_provider (func) – 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).

  • thumbnail_dict_provider_async (func) – Returns a dictionary of thumbnails for the current folder. It is called from an async thread and typically queries a remote server, e.g. Nucleus. Signature: async dict thumbnail_dict_provider_async(item: FileBrowserItem). Returns a dictionary with item name as key, and fullpath to thumbnail file as value.

  • icon_provider (func) – This callback provides an icon to replace the default in the tree view. Signature str icon_provider(item: FileBrowserItem)

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

  • error_handler (func) – This function is called with error messages when appropriate. It provides the calling app a way to display errors. Function signature: void error_handler(message: str).

add_bookmark_with_callback(name: str, path: str, callback: Callable) → omni.kit.widget.filebrowser.model.FileBrowserModel

Creates a FileBrowserModel rooted at the given path, and connects its subtree to the tree view.

Parameters
  • name (str) – Name of the bookmark.

  • path (str) – Fullpath of the connection, e.g. “omniverse://ov-content”. Paths to Omniverse servers should contain the prefix, “omniverse://”.

  • callback (func) – Invokes this callback upon success. A typical use is to update settings. Function signature: void callback(name: str, path: str).

Returns

FileBrowserModel

add_server_with_callback(name: str, path: str, callback: Callable) → omni.kit.widget.filebrowser.model.FileBrowserModel

Creates a FileBrowserModel rooted at the given path, and connects its subtree to the tree view.

Parameters
  • name (str) – Name, label really, of the connection.

  • path (str) – Fullpath of the connection, e.g. “omniverse://ov-content”. Paths to Omniverse servers should contain the prefix, “omniverse://”.

  • callback (func) – Invokes this callback upon success. A typical use is to update saved settings. Function signature: void callback(name: str, path: str).

Returns

FileBrowserModel

Raises

RuntimeWarning – If unable to add server.

all_connection_items(collection: Optional[str] = None) → List[omni.kit.widget.filebrowser.model.FileBrowserItem]

Returns all connections as items for the specified collection. If collection is ‘None’, then return connections from all collections.

Parameters

collection (str) – One of [‘bookmarks’, ‘omniverse’, ‘my-computer’]. Default None.

Returns

All connections found.

Return type

List[FileBrowserItem]

all_connections(collection: Optional[str] = None) → List[str]

Returns all connection paths for the specified collection. If collection is ‘None’, then return connections from all collections.

Parameters

collection (str) – One of [‘bookmarks’, ‘omniverse’, ‘my-computer’]. Default None.

Returns

All connection paths found.

Return type

List[str]

property collections

Dictionary of collections, e.g. ‘bookmarks’, ‘omniverse’, ‘my-computer’.

Type

dict

delete_bookmark_with_callback(item: omni.kit.widget.filebrowser.model.FileBrowserItem, callback: Callable)

Deletes the given bookmark.

Parameters
  • item (FileBrowserItem) – Bookmark item.

  • callback (func) – Invokes this callback upon success. A typical use is to update settings. Function signature: void callback(name: str, path: str).

delete_server_with_callback(item: omni.kit.widget.filebrowser.model.FileBrowserItem, callback: Callable)

Disconnects the subtree rooted at the given item.

Parameters
  • item (FileBrowserItem) – Root of subtree to disconnect.

  • callback (func) – Invokes this callback upon success. A typical use is to update settings. Function signature: void callback(name: str, path: str).

get_root(pane: Optional[int] = None) → omni.kit.widget.filebrowser.model.FileBrowserItem

Returns the root item of the specified pane.

Parameters

pane (int) – One of {TREEVIEW_PANE, LISTVIEW_PANE}.

get_selections(pane: Optional[int] = None) → [<class ‘omni.kit.widget.filebrowser.model.FileBrowserItem’>]

Returns list of currently selected items.

Parameters

pane (int) – One of {TREEVIEW_PANE, LISTVIEW_PANE}.

Returns

list[FileBrowserItem]

has_connection_with_name(name: str, collection: Optional[str] = None)bool

Returns True if speficied connection exists within the collection.

Parameters
  • name (str) – name of connection

  • collection (str) – One of {‘bookmarks’, ‘omniverse’, ‘my-computer’}. Default None.

Returns

bool

is_bookmark(item: omni.kit.widget.filebrowser.model.FileBrowserItem)bool

Returns true if given item is a bookmarked item.

Parameters

item (FileBrowserItem) – Item in question.

Returns

bool

is_connection_point(item: omni.kit.widget.filebrowser.model.FileBrowserItem)bool

Returns true if given item is a direct child of a collection node.

Parameters

item (FileBrowserItem) – Item in question.

Returns

bool

mount_user_folders(folders: dict)

Mounts given set of user folders under the local collection.

Parameters

folders (dict) – Name, path pairs.

reconnect_server(item: omni.kit.widget.filebrowser.model.FileBrowserItem)

Reconnects the server at the given path. Clears out any cached authentication tokens to force the action.

Parameters

item (FileBrowserItem) – Connection item.

refresh_ui(item: Optional[omni.kit.widget.filebrowser.model.FileBrowserItem] = None)

Redraws 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.

rename_bookmark_with_callback(item: omni.kit.widget.filebrowser.model.FileBrowserItem, new_name: str, callback: Callable)

Renames the bookmark item. Note: doesn’t change the connection itself, only how it’s labeled in the tree view.

Parameters
  • item (FileBrowserItem) – Bookmark item.

  • new_name (str) – New name.

  • callback (func) – Invokes this callback upon success. A typical use is to update settings. Function signature: void callback(name: str, path: str, old_name: str).

rename_server_with_callback(item: omni.kit.widget.filebrowser.model.FileBrowserItem, new_name: str, callback: Callable)

Renames the connection item. Note: doesn’t change the connection itself, only how it’s labeled in the tree view.

Parameters
  • item (FileBrowserItem) – Root of subtree to disconnect.

  • new_name (str) – New name.

  • callback (func) – Invokes this callback upon success. A typical use is to update settings. Function signature: void callback(name: str, path: str, old_name: str).

scale_grid_view(scale: float)

Scale file picker’s grid view icon size.

Parameters

scale (float) – Scale of the icon.

select_and_center(item: omni.kit.widget.filebrowser.model.FileBrowserItem)

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

Parameters

item (FileBrowserItem) – The selected item.

show_model(model: omni.kit.widget.filebrowser.model.FileBrowserModel)

Displays the model on the right side of the split pane

toggle_grid_view(show_grid_view: bool)

Toggles file picker between grid and list view.

Parameters

show_grid_view (bool) – True to show grid view, False to show list view.

class omni.kit.window.filepicker.FilePickerModel(theme='NvidiaDark', timeout=3.0)

Bases: object

The model class for FilePickerWidget.

add_saved_bookmark(name: str, path: str)

When a bookmark is added, update the settings dictionary.

add_saved_connection(name: str, path: str)

When a connection is added, update the settings dictionary.

assert_settings_name_exists(settings_name: str)

Checks that specified setting exists. If not, then create empty placeholder.

Parameters

settings_name (str) – Name of the setting.

property collections

The collections loaded for this widget

Type

[FileBrowseItem]

create_folder_with_callback(item: omni.kit.widget.filebrowser.model.FileBrowserItem, folder_name: str, callback: Optional[Callable] = None)

Creates folder under given item. Upon success, executes the given callback.

Parameters
  • item (FileBrowserItem) – Item under which to create the folder.

  • folder_name (str) – Name of new folder.

  • callback (func) – Callback to execute upon success. Function signature is void callback([str]).

Raises

Exception

delete_items_with_callback(items: [<class 'omni.kit.widget.filebrowser.model.FileBrowserItem'>], callback: Optional[Callable] = None)

Deletes given items. Upon success, executes the given callback.

Parameters
  • items ([FileBrowserItem]) – Items to delete.

  • callback (func) – Callback to execute upon success. Function signature is void callback([str]).

Raises

Exception

delete_saved_bookmark(name: str, path: str)

When a connection is deleted, update the settings dictionary.

delete_saved_connection(name: str, path: str)

When a connection is deleted, update the settings dictionary.

filter_item(item: omni.kit.widget.filebrowser.model.FileBrowserItem)bool

Default item filter callback. Returning True displays the item.

Parameters

item (FileBrowseritem) – Item in question.

Returns

bool

find_item_with_callback(path: str, callback: Callable)

Searches model for the given path and executes callback on found item.

Parameters
  • path (str) – Path of item to search for.

  • callback (func) – Invokes this callback on found item or None if not found. Function signature is void callback(item: FileBrowserItem)

get_asset_type(item: omni.kit.widget.filebrowser.model.FileBrowserItem)str

Returns asset type of given item.

Parameters

item (FileBrowseritem) – Item in question.

Returns

str

get_badges(item: omni.kit.widget.filebrowser.model.FileBrowserItem) → List[str]

Returns fullpaths to badges for given item. Override this method to implement custom badges.

Parameters

item (FileBrowseritem) – Item in question.

Returns

[str]

get_displayed_path(item: omni.kit.widget.filebrowser.model.FileBrowserItem, path: str = '')str

Returns displayed path, as opposed to the system path. I.e. this is the path derived by traversing from the root of the tree view to the given item. The tree view path may be different from the system path if some folder names are aliased, e.g. symbolic links.

Parameters
  • item (FileBrowserItem) – Specified item.

  • path (str, optional) – Path should be left empty initially and extended recursively.

Returns

str

get_icon(item: omni.kit.widget.filebrowser.model.FileBrowserItem, expanded: bool)str

Returns fullpath to icon for given item. Override this method to implement custom icons.

Parameters
  • item (FileBrowseritem) – Item in question.

  • expanded (bool) – True if item is expanded.

Returns

str

get_saved_bookmarks_dict()dict

Returns dictionary of saved bookmarks as name, path pairs

get_saved_connections_dict()dict

Returns persistent connections as dict.

Returns

dict

get_thumbnail(item: omni.kit.widget.filebrowser.model.FileBrowserItem)str

Returns fullpath to thumbnail for given item.

Parameters

item (FileBrowseritem) – Item in question.

Returns

Fullpath to the thumbnail file, None if not found.

Return type

str

async get_thumbnail_dict_async(_: omni.kit.widget.filebrowser.model.FileBrowserModel, item: omni.kit.widget.filebrowser.model.FileBrowserItem, retry=True)dict

Returns a dictionary of thumbnails for the current folder by listing the adjacent “.thumbs” folder.

Parameters
  • model (FileBrowsermodel) – Ignored.

  • item (FileBrowseritem) – Current folder.

Returns

With item name as key, and fullpath to thumbnail file as value.

Return type

dict

get_user_folders_dict()dict

Returns dictionary of user folders as name, path pairs

is_asset_type(item: omni.kit.widget.filebrowser.model.FileBrowserItem, asset_type: str)bool

Returns True if given item is of specified type.

Parameters
  • item (FileBrowseritem) – Item in question.

  • asset_type (str) – Tested type name.

Returns

bool

is_local_path(path: str)bool

Returns True if given path is a local path

register_file_extensions(asset_type: str, exts: [<class 'str'>], replace: bool = False)

Adds an asset type to the recognized list.

Parameters
  • asset_type (str) – Name of asset type.

  • exts ([str]) – List of extensions to associate with this asset type, e.g. [“.usd”, “.usda”].

  • replace (bool) – If True, replaces extensions in the existing definition. Otherwise, append to the existing list.

rename_saved_bookmark(name: str, path: str, prev_name: str)

When a connection is deleted, update the settings dictionary.

rename_saved_connection(name: str, path: str, old_name: str)

When a connection is renamed, update the settings dictionary.

sanitize_path(path: str)str

Helper function for normalizing a path that may have been copied and pasted int to browser bar. This makes the tool more resiliant to user inputs from other apps.

Parameters

path (str) – Raw path

Returns

str

class omni.kit.window.filepicker.FilePickerAPI(model: Optional[omni.kit.window.filepicker.model.FilePickerModel] = None, view: Optional[omni.kit.window.filepicker.view.FilePickerView] = None, timeout=10.0)

Bases: object

This class defines the API methods for FilePickerWidget.

add_connections(connections: dict)

Adds specified server connections to the tree browser. To facilitate quick startup time, doesn’t check whether the connection is actually valid.

Parameters

connections (dict) – A dictionary of name, path pairs. For example: {“C:”: “C:”, “ov-content”: “omniverse://ov-content”}. Paths to Omniverse servers should be prefixed with “omniverse://”.

add_context_menu(name: str, glyph: str, click_fn: Callable, show_fn: Callable, index: int = - 1)str

Adds menu item, with corresponding callbacks, to the context menu.

Parameters
  • name (str) – Name of the menu item (e.g. ‘Open’), this name must be unique across the context menu.

  • glyph (str) – Associated glyph to display for this menu item.

  • click_fn (func) – This callback function is executed when the menu item is clicked. Function signature: void fn(name: str, path: str), where name is menu name and path is absolute path to clicked item.

  • show_fn (func) – Returns True to display this menu item. Function signature: bool fn(path: str). For example, test filename extension to decide whether to display a ‘Play Sound’ action.

  • index (int) – The postion that this menu item will be inserted to.

Returns

Name of menu item if successful, None otherwise.

Return type

str

add_detail_frame(name: str, glyph: str, build_fn: Callable[], omni.ui._ui.Widget], selection_changed_fn: Callable[[List[str]], None], destroy_fn: Callable[[omni.ui._ui.Widget], None]) → omni.ui._ui.Widget

Adds subsection to the detail view, and populate it with a custom built widget.

Parameters
  • name (str) – Name of the widget sub-section, this name must be unique over all detail sub-sections.

  • glyph (str) – Associated glyph to display for this subj-section

  • build_fn (func) – This callback function builds the widget. Function signature: ui.Widget build_fn().

  • selection_changed_fn (Callable) – This callback is invoked by parent to handle selection changes.

  • destroy_fn (func) – Cleanup function called when destroyed. Function signature: void destroy_fn(widget: ui.Widget).

Returns

Handle to created widget.

Return type

ui.Widget

add_listview_menu(name: str, glyph: str, click_fn: Callable, show_fn: Callable, index: int = - 1)str

Adds menu item, with corresponding callbacks, to the list view menu.

Parameters
  • name (str) – Name of the menu item (e.g. ‘Open’), this name must be unique across the list view menu.

  • glyph (str) – Associated glyph to display for this menu item.

  • click_fn (func) – This callback function is executed when the menu item is clicked. Function signature: void fn(name: str, path: str), where name is menu name and path is absolute path to clicked item.

  • show_fn (func) – Returns True to display this menu item. Function signature: bool fn(path: str). For example, test filename extension to decide whether to display a ‘Play Sound’ action.

  • index (int) – The postion that this menu item will be inserted to.

Returns

Name of menu item if successful, None otherwise.

Return type

str

delete_context_menu(name: str)

Deletes the menu item, with the given name, from the context menu.

Parameters

name (str) – Name of the menu item (e.g. ‘Open’).

delete_detail_frame(name: str)

Deletes the specified detail subsection.

Parameters

name (str) – Name of the subsection.

delete_listview_menu(name: str)

Deletes the menu item, with the given name, from the list view menu.

Parameters

name (str) – Name of the menu item (e.g. ‘Open’).

find_subdirs_with_callback(path: str, callback: Callable)

Returns list of subdirectories for given path.

Parameters
  • path (str) – Path.

  • callback (func) – On success executes this callback with the list of subdir names. Function signature: void callback(subdirs: List[str])

get_current_directory()str

Returns the current directory fom the browser bar.

Returns

The system path, which may be different from the displayed path.

Return type

str

get_current_selections(pane: int = 2) → List[str]

Returns current selected as list of system path names.

Parameters

pane (int) – Specifies pane to retrieve selections from, one of {TREEVIEW_PANE = 1, LISTVIEW_PANE = 2, BOTH = None}. Default LISTVIEW_PANE.

Returns

List of system paths (which may be different from displayed paths, e.g. bookmarks)

Return type

[str]

get_filename()str
Returns

Currently selected filename.

Return type

str

navigate_to(path: str, callback: Optional[Callable] = None)

Navigates to a path, i.e. the path’s parent directory will be expanded and leaf selected. This method is used to process the path coming from the browser bar.

Parameters
  • path (str) – The path to navigate to.

  • callback (func) – On successly finding the item, executes this callback. Function signature: void callback(item: FileBrowserItem)

refresh_current_directory()

Refreshes the current directory set in the browser bar.

set_current_directory(path: str)

Procedurally sets the current directory. Use this method to set the path in the browser bar.

Parameters

path (str) – The full path name of the folder, e.g. “omniverse://ov-content/Users/me.

set_filename(filename: str)

Sets the filename in the file bar, at bottom of the dialog. The file is not required to already exist.

Parameters

filename (str) – The filename only (and not the fullpath), e.g. “myfile.usd”.

subscribe_bookmarks_settings_changed()

Updates bookmarks when settings changed.

subscribe_connections_settings_changed()

Updates connections when settings changed.

toggle_bookmark_from_path(name: str, path: str, is_bookmark: bool)

Adds/deletes the given bookmark with the specified path. If deleting, then the path argument is optional.

Parameters
  • name (str) – Name to call the bookmark or existing name if delete.

  • path (str) – Path to the bookmark.

  • is_bookmark (bool) – True to add, False to delete.

class omni.kit.window.filepicker.ContextMenu(**kwargs)

Bases: object

Creates popup menu for the hovered FileBrowserItem. In addition to the set of default actions below, users can add more via the add_menu_item API.

Keyword Arguments
  • rename_item_fn – void rename_item(item: FileBrowserItem, new_name: str). Default None.

  • create_folder_fn – void create_folder(item: FileBrowserItem, name: str). Default None.

  • add_bookmark_fn – void add_bookmark(item: FileBrowserItem, name: str). Default None.

  • delete_bookmark_fn – void delete_bookmark(item: FileBrowserItem). Default None.

  • delete_items_fn – void delete_items(items: [FileBrowserItem]). Default None.

  • reconnect_server_fn – void reconnect_server(item: FileBrowserItem). Default None.

  • remove_connection_fn – void remove_connection(item: FileBrowserItem). Default None.

  • refresh_item_fn – void refresh_item(item: FileBrowserItem). Default None.

add_menu_item(name: str, glyph: str, onclick_fn: Callable, show_fn: Callable, index: int = - 1)str

Adds menu item, with corresponding callbacks, to this context menu.

Parameters
  • name (str) – Name of the menu item (e.g. ‘Open’), this name must be unique across the context menu.

  • glyph (str) – Associated glyph to display for this menu item.

  • onclick_fn (func) – This callback function is executed when the menu item is clicked. Function signature: void fn(name: str, path: str), where name is menu name and path is absolute path to clicked item.

  • show_fn (func) – Returns True to display this menu item. Function signature: bool fn(path: str). For example, test filename extension to decide whether to display a ‘Play Sound’ action.

  • index (int) – The position that this menu item will be inserted to.

Returns

Name of menu item if successful, None otherwise.

Return type

str

property context

Provides data to the callback. Available keys are {‘item’, ‘is_bookmark’, ‘is_connection’, ‘selected’}

Type

dict

delete_menu_item(name: str)

Deletes the menu item, with the given name, from this context menu.

Parameters

name (str) – Name of the menu item (e.g. ‘Open’).

property menu

omni.ui.Menu The menu widget

show(item: omni.kit.widget.filebrowser.model.FileBrowserItem, is_bookmark: bool = False, is_connection_point: bool = False, selected: [<class 'omni.kit.widget.filebrowser.model.FileBrowserItem'>] = [])

Creates the popup menu from definition for immediate display. Receives as input, information about the item. These values are made available to the callback via the ‘context’ dictionary.

Parameters
  • item (FileBrowseritem) – Item for which to create menu.,

  • is_bookmark (bool) – True if this item is a bookmark. Default False.

  • is_connection_point (bool) – True if item is a connection point. Default False.

  • selected ([FileBrowserItem]) – List of currently selected items. Default [].