Open a File Browser Dialog#

We provide standardized file browsing dialogs so that users have a familiar file browsing experience no matter where or from which extension they are prompted to browse for files. If you want to prompt the user to select one or more files to read from, use the File Importer Extension (omni.kit.window.file_importer). If you want to prompt the user to select a file to save or export to, use the File Exporter Extension.

File Import Dialog#

This snippet shows basic usage of the FileImporterExtension. Check the File Importer Extension for more examples and information about its features.

from omni.kit.window.file_importer import get_file_importer

def import_handler(filename: str, dirname: str, selections: List[str] = []):
    print(f"> Import '{filename}' from '{dirname}' or selected files '{selections}'")

# Get the singleton extension.
file_importer = get_file_importer()
file_importer.show_window(
    title="Import File",
    # The callback function called after the user has selected a file.
    import_handler=import_handler
)

File Export Dialog#

This snippet shows basic usage of the FileExporterExtension. Check the File Exporter Extension for more examples and information about its features.

from omni.kit.window.file_exporter import get_file_exporter

def export_handler(self, filename: str, dirname: str, extension: str = "", selections: List[str] = []):
    print(f"> Export As '{filename}{extension}' to '{dirname}' with additional selections '{selections}'")

# Get the singleton extension object, but as weakref to guard against the extension being removed.
file_exporter = get_file_exporter()
file_exporter.show_window(
    title="Export As ...",
    export_button_label="Save",
    # The callback function called after the user has selected an export location.
    export_handler=export_handler,
    filename_url="omniverse://ov-rc/NVIDIA/Samples/Marbles/foo",
)