FileBrowser
File/directory browser at the server side.
@solara.component
def FileBrowser(
directory: Union[None, str, Path, solara.Reactive[Path]] = None,
selected: Union[None, Path, solara.Reactive[Optional[Path]]] = None,
on_directory_change: Optional[Callable[[Path], None]] = None,
on_path_select: Optional[Callable[[Optional[Path]], None]] = None,
on_file_open: Optional[Callable[[Path], None]] = None,
filter: Callable[[Path], bool] = lambda x: True,
directory_first: bool = False,
on_file_name: Optional[Callable[[str], None]] = None,
start_directory=None,
can_select=False,
watch: bool = False,
):
...
There are two modes possible
can_select=Falseon_file_open: Triggered when single clicking a file or directory.on_path_select: Never triggeredon_directory_change: Triggered when clicking a directorycan_select=Trueon_file_open: Triggered when double clicking a file or directory.on_path_select: Triggered when clicking a file or directoryon_directory_change: Triggered when double clicking a directory
Arguments
directory: The directory to start in. IfNone, the current working directory is used.selected: The selected file or directory. IfNone, no file or directory is selected (requirescan_select=True).on_directory_change: Depends on mode, see above.on_path_select: Depends on mode, see above.on_file_open: Depends on mode, see above.filter: A function that takes aPathand returnsTrueif the file/directory should be shown.directory_first: IfTruedirectories are shown before files. Default:False.on_file_name: (deprecated) Use on_file_open instead.start_directory: (deprecated) Use directory instead.watch: IfTrue, watch the current directory for file changes and automatically refresh the file list. Requires thewatchfilespackage to be installed.
Example
/home/runner
..
actions-runner
work
You are in directory: PosixPath('/home/runner')
You selected path: None
You opened file: None