omni.kit.window.content_browser¶
A window extension for browsing Omniverse content.
-
class
omni.kit.window.content_browser.
ContentBrowserExtension
¶ The Content Browser extension
-
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.
- 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
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) → [<class ‘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]
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 the all parent directories in the path.
- Parameters
url (str) – The url 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_search_delegate
(delegate: omni.kit.window.filepicker.search_delegate.SearchDelegate)¶ Sets a custom search delegate for the tool bar.
- Parameters
delegate (
SearchDelegate
) – Object that creates the search widget.
-
show_model
(model: omni.kit.widget.filebrowser.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.
- Returns
carb.Subscription object, or None if subscription failed.
-
toggle_bookmark_from_path
(name: str, path: str, is_bookmark: bool) → 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.
- 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.
-
property
window
¶ Main dialog window for this extension.
- Type
ui.Window
-
-
class
omni.kit.window.content_browser.
ContentBrowserWindow
(import_menu: Optional[omni.kit.window.content_browser.tool_bar.ImportMenu])¶ The Content Browser window
-
class
omni.kit.window.content_browser.
ContentBrowserWidget
(**kwargs)¶ The Content Browser widget
-
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
Name if successful, None otherwise.
- Return type
str
Adds 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
-
property
api
¶ Provides API methods to this widget.
- Type
FilePickerAPI
-
delete_file_open_handler
(name: str)¶ Unregisters the named file open handler.
- Parameters
name (str) – Name of the handler.
Deletes the menu item, with the given name, from the Import combo box.
- Parameters
name (str) – Name of the menu item.
-
-
class
omni.kit.window.content_browser.
ContentBrowserModel
(timeout=3.0)¶ The model class for
ContentBrowserWidget
.-
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 url submitted to browser bar. Function signature: void open_fn(url: str).
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(url: str).
- Returns
Name if successful, None otherwise.
- Return type
str
-
delete_file_open_handler
(name: str)¶ Unregisters the named file open handler.
- Parameters
name (str) – Name of the handler.
-
download_items_with_callback
(dst_url: str, src_urls: List[str], callback: Optional[Callable] = None)¶ Downloads specified items. Upon success, executes the given callback.
- Parameters
dst_url (str) – Destination folder.
src_urls ([str]) – Paths of items to download.
callback (Callable) – Callback to execute upon success. Function signature is void callback([str]).
- Raises
Exception –
-
get_file_open_handler
(url: str) → Callable¶ Returns the matching file open handler for the given item.
- Parameters
str (url) – The url of the item to open.
-
async
open_stage_async
(url: str, open_loadset=UsdContextInitialLoadSet.LOAD_ALL)¶ Async function for opening a USD file.
- Parameters
url (str) – Url to file.
-
async
open_with_new_edit_layer
(url: str, open_loadset=UsdContextInitialLoadSet.LOAD_ALL)¶ Async function for opening a USD file, then creating a new layer.
- Parameters
url (str) – Url to file.
-
subscribe_selection_changed
(fn: Callable) → carb._carb.Subscription¶ Subscribes to file selection changes.
- Parameters
fn (Callable) – callback function when file selection changed.
- Returns
carb.Subscription object.
-
-
omni.kit.window.content_browser.
get_content_window
() → omni.kit.window.content_browser.extension.ContentBrowserExtension¶ Returns cached
ContentBrowserExtension
interface