FilePickerAPI
- class omni.kit.window.filepicker.FilePickerAPI(model: Optional[FilePickerModel] = None, view: Optional[FilePickerView] = None)
Bases:
object
This class defines the API methods for
FilePickerWidget
.Methods
__init__
([model, view])Initialize the FilePickerAPI.
add_collection
(collection_data)Add custom collection to current content view.
add_connections
(connections)Adds specified server connections to the tree browser.
add_context_menu
(name, glyph, click_fn, show_fn)Adds menu item, with corresponding callbacks, to the context menu.
add_detail_frame
(name, glyph, build_fn[, ...])Adds sub-frame to the detail view, and populates it with a custom built widget.
add_detail_frame_from_controller
(name, ...)Adds sub-frame to the detail view, and populates it with a custom built widget.
add_listview_menu
(name, glyph, click_fn, show_fn)Adds menu item, with corresponding callbacks, to the list view menu.
add_show_only_collection
(collection_id)Add a filter to show collections.
connect_server
(url[, callback])Connects the server for given url.
delete_context_menu
(name)Deletes the menu item, with the given name, from the context menu.
delete_detail_frame
(name)Deletes the specified detail subsection.
delete_listview_menu
(name)Deletes the menu item, with the given name, from the list view menu.
destroy
()Destructor.
find_subdirs_async
(url, callback)Asynchronously executes callback on list of subdirectories at given url.
find_subdirs_with_callback
(url, callback)Executes callback on list of subdirectories at given url.
Returns the current directory fom the browser bar.
get_current_selections
([pane])Returns current selected as list of system path names.
- returns
Currently selected filename.
Hide the loading icon if it exist.
navigate_to
(url[, callback])Navigates to the given url, expanding all parent directories in the path.
navigate_to_async
(url[, callback])Asynchronously navigates to the given url, expanding the all parent directories in the path.
Refreshes the current directory set in the browser bar.
remove_collection
(collection_id)Remove custom collection from current content view.
remove_show_only_collection
(collection_id)Remove the collection filter
select_items_async
(url[, filenames])Asynchronously select one or more items in the content view.
set_current_directory
(path)Procedurally sets the current directory.
set_filename
(filename)Sets the filename in the file bar, at bottom of the dialog.
set_search_delegate
(delegate)Sets a custom search delegate for the tool bar.
show_model
(model)Displays the given model in the list view, overriding the default model.
Subscribe to omni.client bookmark changes.
toggle_bookmark_from_path
(name, path, ...[, ...])Adds/deletes the given bookmark with the specified path.
- __init__(model: Optional[FilePickerModel] = None, view: Optional[FilePickerView] = None)
Initialize the FilePickerAPI.
- Parameters
( (view) – obj:’FilePickerModel’): The model background, default None.
( – obj:’FilePickerView’): the content view object. Default None.
- add_collection(collection_data: CollectionData)
Add custom collection to current content view. samples of collection: “My Computer”, “Omniverse Bookmark”, …
- Parameters
collection_data (CollectionData) – Data to add.
- 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://”.
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 (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 postion 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_detail_frame(name: str, glyph: str, build_fn: Callable[[], None], selection_changed_fn: Optional[Callable[[List[str]], None]] = None, filename_changed_fn: Optional[Callable[[str], None]] = None, destroy_fn: Optional[Callable[[], None]] = None)
Adds sub-frame to the detail view, and populates 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 (Callable) – This callback function builds the widget.
- Keyword Arguments
selection_changed_fn (Callable) – This callback is invoked to handle selection changes.
filename_changed_fn (Callable) – This callback is invoked when filename is changed.
destroy_fn (Callable) – Cleanup function called when destroyed.
- add_detail_frame_from_controller(name: str, controller: DetailFrameController)
Adds sub-frame to the detail view, and populates 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.
controller (
DetailFrameController
) – Controller object that encapsulates all aspects of creating, updating, and deleting a detail frame widget.
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 (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 postion that this menu item will be inserted to.
- Returns
Name of menu item if successful, None otherwise.
- Return type
str
- add_show_only_collection(collection_id: str)
Add a filter to show collections. If this collection filter is provided, only those that match the filter will be shown, other collections will be hidden. Otherwise all collections are shown.
- Parameters
collection_id (str) – the filter.
- connect_server(url: str, callback: Optional[Callable] = None)
Connects the server for given url.
- Parameters
url (str) – Given url.
callback (Callable) – On successfully connecting the server, executes this callback. Function signature: void callback(name: str, server_url: 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 previously assigned to the detail frame.
Deletes the menu item, with the given name, from the list view menu.
- Parameters
name (str) – Name of the menu item (e.g. ‘Open’).
- destroy()
Destructor.
- async find_subdirs_async(url: str, callback: Callable) List[str]
Asynchronously executes callback on list of subdirectories at given url.
- Parameters
url (str) – Url.
callback (Callable) – On success executes this callback with the list of subdir names. Function signature: void callback(subdirs: List[str])
- find_subdirs_with_callback(url: str, callback: Callable)
Executes callback on list of subdirectories at given url.
- Parameters
url (str) – Url.
callback (Callable) – 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
- hide_loading_pane()
Hide the loading icon if it exist.
Navigates to the given url, expanding all parent directories in the path.
- Parameters
url (str) – The url to navigate to.
callback (Callable) – On successfully finding the item, executes this callback. Function signature: void callback(item: FileBrowserItem)
Asynchronously navigates to the given url, expanding the all parent directories in the path.
- Parameters
url (str) – The url to navigate to.
callback (Callable) – On successfully finding the item, executes this callback. Function signature: void callback(item: FileBrowserItem)
- refresh_current_directory()
Refreshes the current directory set in the browser bar.
- remove_collection(collection_id: str)
Remove custom collection from current content view. samples of collection: “My Computer”, “Omniverse Bookmark”, …
- Parameters
collection_id (str) – Data id to remove.
- remove_show_only_collection(collection_id: str)
Remove the collection filter
- Parameters
collection_id (str) – The filter that previously added.
- async select_items_async(url: str, filenames: List[str] = []) List[FileBrowserItem]
Asynchronously select one or more items in the content view.
- Parameters
url (str) – Url.
- Keyword Arguments
filenames (List[str]) – A list of file names that to be selected
- 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”.
- set_search_delegate(delegate)
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.
- subscribe_client_bookmarks_changed()
Subscribe to omni.client bookmark changes.
- toggle_bookmark_from_path(name: str, path: str, is_bookmark: bool, is_folder: bool = True)
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.