Introduction
TeamFilesSelector
is a graphic interface widget in the Supervisely platform that enables users to easily select files and/or folders from their Team files. It allows to customize selecting type (files, folder or both of this types) and displaying additional columns with information about files and folder (size, created date, updated date, type, mime type). The widget features a user-friendly interface and is optimized for performance, making it a valuable tool for teams working.
Function signature
Copy TeamFilesSelector (
team_id = 435 ,
multiple_selection = False ,
max_height = 500 ,
selection_file_type = None ,
hide_header = True ,
hide_empty_table = True ,
additional_fields = [],
widget_id = None ,
)
Parameters
Parameters Type Description Whether available selection multiple files/folders
Determine maximum height of the widget
Literal["folder", "file"]
or None
Determine type of items available for selection
If True
hide widget table header
If True
and Team files directory is empty it will display message
List[Literal["id", "createdAt", "updatedAt", "type", "size", "mimeType"]]
Determine column names to display additional information about files/folders
team_id
Team ID
type: int
Copy file_selector = TeamFilesSelector (team_id = 435 )
multiple_selection
Whether available selection multiple files/folders
type: bool
default value: False
Copy file_selector = TeamFilesSelector (
team_id = 435 ,
multiple_selection = True ,
)
Copy file_selector = TeamFilesSelector (
team_id = 435 ,
multiple_selection = True ,
)
max_height
Determine maximum height of the widget
type: int
default value: 500
Copy file_selector = TeamFilesSelector (
team_id = 435 ,
max_height = 200 ,
)
If True
hide widget table header
type bool
default value: True
Copy file_selector = TeamFilesSelector (
team_id = 435 ,
hide_header = False
)
selection_file_type
Determine type of items available for selection
type: Literal["folder", "file"]
or None
default value: None
Copy file_selector = TeamFilesSelector (
team_id = 435 ,
selection_file_type = None ,
)
Copy file_selector = TeamFilesSelector (
team_id = 435 ,
selection_file_type = "file"
)
Copy file_selector = TeamFilesSelector (
team_id = 435 ,
selection_file_type = "folder"
)
hide_empty_table
If True
and Team files directory is empty it will display message
type: bool
default value: True
Copy file_selector = TeamFilesSelector (
team_id = 435 ,
hide_empty_table = True ,
)
Copy file_selector = TeamFilesSelector (
team_id = 435 ,
hide_empty_table = False ,
)
additional_fields
Determine column names to display additional information about files/folders
type: List[Literal["id", "createdAt", "updatedAt", "type", "size", "mimeType"]]
default value: []
Copy file_selector = TeamFilesSelector (
team_id = 435 ,
hide_header = False ,
additional_fields = [ "id" , "createdAt" , "updatedAt" , "type" , "size" , "mimeType" ],
)
widget_id
ID of the widget
type: str
default value: ``
Methods and attributes
Attributes and Methods Description Get list of path for selected files/folders in Team files.
Get list of selected files/folders information in Team files.
set_team_id(team_id: int)
Set team_id
for TeamFilesSelector
widget.
Mini App Example
You can find this example in our Github repository:
supervisely-ecosystem/ui-widgets-demos/selection/012_team_files_selector/src/main.py
Import libraries
Copy import os
import supervisely as sly
from dotenv import load_dotenv
from supervisely . app . widgets import Button , Card , Container , TeamFilesSelector , Text
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Copy load_dotenv ( "local.env" )
load_dotenv (os.path. expanduser ( "~/supervisely.env" ))
api = sly . Api ()
Get team_id
from environment variables
Copy team_id = sly . env . team_id ()
Initialize TeamFilesSelector
widget
Copy file_selector = TeamFilesSelector (
team_id = team_id,
max_height = 300 ,
multiple_selection = True ,
selection_file_type = "folder" ,
hide_header = False ,
additional_fields = [ "createdAt" , "type" , "size" ],
)
Create Text
, Button
widgets we will use in UI for demo
Copy text = Text ()
button = Button ()
Create 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.
Copy card = Card (
title = "Team Files Selector" ,
content = Container ([file_selector, button, text]),
)
layout = Container (widgets = [card])
Create app using layout
Create an app object with layout parameter.
Copy app = sly . Application (layout = layout)
Add functions to control widgets from code
Copy @button . click
def show_selected ():
selected_paths = file_selector . get_selected_paths ()
text . text = "<br>" . join (selected_paths)