FilePicker
- class omni.kit.property.layer.file_picker.FilePicker(title: str, apply_button_name: str, selection_type: FileBrowserSelectionType = 2, item_filter_options: Iterable[Tuple[Union[Pattern, str], str]] = (re.compile('.*'), 'All Files (*.*)'))
Bases:
object
A class for creating a file selection dialog.
This class provides a user interface to select files or directories from the filesystem.
- Parameters
title (str) – The title of the file picker window.
apply_button_name (str) – The label of the apply button in the dialog.
selection_type (
FileBrowserSelectionType
) – The type of selection to allow (file, directory, or both).item_filter_options (Iterable[Tuple[Union[re.Pattern, str], str]]) – A list of filter options for limiting the files that can be selected. Each filter option is a tuple where the first element is a regex pattern (as a string or compiled regex object) that files must match, and the second element is a human-readable description of the filter.
Methods
__init__
(title, apply_button_name[, ...])Initializes the FilePicker with custom configurations.
destroy
()Cleans up the file picker and destroys the file picker dialog.
Hides the file picker dialog.
Sets the current directory for the file picker.
set_current_filename
(filename)Sets the filename in the file picker's dialog.
set_custom_fn
(select_fn, cancel_fn)Sets custom functions for select and cancel actions.
Displays the file picker dialog using the current directory.
- __init__(title: str, apply_button_name: str, selection_type: FileBrowserSelectionType = 2, item_filter_options: Iterable[Tuple[Union[Pattern, str], str]] = (re.compile('.*'), 'All Files (*.*)'))
Initializes the FilePicker with custom configurations.
- destroy()
Cleans up the file picker and destroys the file picker dialog.
- hide_dialog()
Hides the file picker dialog.
- set_current_directory(dir: str)
Sets the current directory for the file picker.
- Parameters
dir (str) – The directory to be set as current.
- set_current_filename(filename: str)
Sets the filename in the file picker’s dialog.
- Parameters
filename (str) – The filename to be set.
- set_custom_fn(select_fn, cancel_fn)
Sets custom functions for select and cancel actions.
- Parameters
select_fn (Callable) – Function to call when a file is selected.
cancel_fn (Callable) – Function to call when the dialog is canceled.
- show_dialog()
Displays the file picker dialog using the current directory.