omni.kit.window.content_browser
A window extension for browsing Omniverse content.
A window extension for browsing filesystem, including Nucleus, content
- class omni.kit.window.content_browser.ContentBrowserExtension
Bases:
IExt
The Content Browser extension
- MENU_GROUP = 'Window'
- WINDOW_NAME = 'Content'
- add_connections(connections: dict)
Adds specified server connections to the tree 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://”.
Add 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 (Callable) – This callback function is executed when the menu item is clicked. Function signature is void fn(name: str, path: str), where name is menu name and path is absolute path to clicked item.
show_fn (Callable) – 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.
separator_name (str) – The separator name of the separator menu item. Default to ‘_placeholder_’. When the index is not explicitly set, or if the index is out of range, this will be used to locate where to add the menu item; if specified, the index passed in will be counted from the saparator with the provided name. This is for OM-86768 as part of the effort to match Navigator and Kit UX for Filepicker/Content Browser for context menus.
- Returns
Name of menu item if successful, None otherwise.
- Return type
str
- add_file_open_handler(name: str, open_fn: Callable, file_type: Union[int, Callable]) str
Registers callback/handler to open a file of matching type.
- Parameters
name (str) – Unique name of handler.
open_fn (Callable) – This function is executed when a matching file is selected for open, i.e. double clicked, right mouse menu open, or path submitted to browser bar. Function signature: void open_fn(full_path: str), full_path is the file’s system path.
file_type (Union[int, func]) – Can either be an enumerated int that is one of: [FILE_TYPE_USD, FILE_TYPE_IMAGE, FILE_TYPE_SOUND, FILE_TYPE_TEXT, FILE_TYPE_VOLUME] or a more general boolean function that returns True if this function should be activated on the given file. Function signature: bool file_type(full_path: str).
- Returns
str - Name if successful, None otherwise.
Add menu item, with corresponding callbacks, to the Import combo box.
- Parameters
name (str) – Name of the menu item, this name must be unique across the menu.
glyph (str) – Associated glyph to display for this menu item.
click_fn (Callable) – 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 (Callable) – 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.
- Returns
Name of menu item if successful, None otherwise.
- Return type
str
Add 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 (Callable) – 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 (Callable) – 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 api: ContentBrowserAPI
- decorate_from_registry(event: IEvent)
Delete the menu item, with the given name, from the context menu.
- Parameters
name (str) – Name of the menu item (e.g. ‘Open’).
- delete_file_open_handler(name: str)
Unregisters the named file open handler.
- Parameters
name (str) – Name of the handler.
Delete the menu item, with the given name, from the Import combo box.
- Parameters
name (str) – Name of the menu item.
Delete the menu item, with the given name, from the list view menu.
- Parameters
name (str) - Name of the menu item (e.g. 'Open') –
- get_checkpoint_widget() CheckpointWidget
Returns the checkpoint widget
- 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
List[str]
- get_file_open_handler(url: str) Callable
Returns the matching file open handler for the given file path.
- Parameters
str (url) – The url of the file to open.
- get_timestamp_widget() TimestampWidget
Returns the timestamp widget
Navigates to the given url, expanding all parent directories along the path.
- Parameters
url (str) – The path to navigate to.
Asynchronously navigates to the given url, expanding all parent directories along the path.
- Parameters
url (str) – The url to navigate to.
- on_shutdown()
- on_startup(ext_id)
- refresh_current_directory()
Refreshes the current directory set in the browser bar.
- async select_items_async(url: str, filenames: List[str] = []) List[FileBrowserItem]
Asynchronously selects display items by their names.
- Parameters
url (str) – Url of the parent folder.
filenames (str) – Names of items to select.
- Returns
List of selected items.
- Return type
List[FileBrowserItem]
- 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_search_delegate(delegate: SearchDelegate)
Sets a custom search delegate for the tool bar.
- Parameters
delegate (SearchDelegate) – Object that creates the search widget.
- show_model(model: FileBrowserModel)
Displays the given model in the list view, overriding the default model. For example, this model might be the result of a search.
- Parameters
model (FileBrowserModel) – Model to display.
- show_window(menu, value)
Shows this window. Inputs are for backwards compatibility only and not used.
- subscribe_selection_changed(fn: Callable)
Subscribes to file selection changes.
- Parameters
fn (Callable) – callback function when file selection changed.
- toggle_bookmark_from_path(name: str, path: str, is_bookmark: bool, is_folder: bool = True) 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.
is_folder (bool) – Whether the item to be bookmarked is a folder.
- Returns
True if successful.
- Return type
bool
- 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.
- unset_search_delegate(delegate: SearchDelegate)
Clears the custom search delegate for the tool bar.
- Parameters
delegate (
SearchDelegate
) – Object that creates the search widget.
- unsubscribe_selection_changed(fn: Callable)
Unsubscribes this callback from selection changes.
- Parameters
fn (Callable) – callback function when file selection changed.
- property window: Window
Main dialog window for this extension.
- Type
ui.Window
- omni.kit.window.content_browser.get_content_window() ContentBrowserExtension
Returns the singleton content_browser extension instance