FileViewer
Introduction
FileViewer widget in Supervisely is a useful tool for inspecting and easily navigation through files in specific directory in Team files.
Function signature
FileViewer(
files_list=files_list,
selection_type=None,
extended_selection=False,
widget_id=None,
)
Parameters
files_list
List[dict]
List of dicts with files and folders info
selection_type
Literal[None, "file", "folder"]
Type of data to select
extended_selection
bool
If True method get_selected_items() returns a list of dict's, instead of list with paths
widget_id
str
ID of the widget
files_list
Determine pathes to files.
type: List[dict]

selection_type
Type of data to select. If set to 'file' - only files can be selected, if set to 'folder' - only folders can be selected. If set to None - both files and folders can be selected.
type: Literal[None, "file", "folder"]
default value: None
extended_selection
If True method get_selected_items() returns a list of dict's, instead of list with paths.
type: bool
default value: False
widget_id
ID of the widget.
type: str
default value: None
Methods and attributes
loading
Get or set loading property.
get_selected_items()
Return selected items.
get_current_path()
Return current path to files.
update_file_tree(files_list: List[dict])
Update files tree by given files list.
@path_changed
Decorator function is handled then input path changed.
@value_changed
Decorator function is handled then input value changed.
Mini App Example
You can find this example in our Github repository:
supervisely-ecosystem/ui-widgets-demos/selection/013_file_viewer/src/main.py
Import libraries
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Get Team ID from environment variables
Prepare file pathes
Initialize FileViewer widget
FileViewer widgetCreate Text widgets we will use
Text widgets we will useCreate app layout
Prepare a layout for app using Card widget with the content parameter and place widget that we've just created in the Container widget.
Create app using layout
Create an app object with layout parameter.
Add function to control widgets from python code

Last updated
Was this helpful?