SelectUser

Introduction

SelectUser widget in Supervisely is a dropdown menu that allows users to select team members from a list of UserInfo objects. It supports features like filtering and multiple selection. This widget is commonly used in applications that need to assign tasks, filter data by user, or manage team member permissions.

Read this tutorial in developer portal.

Function signature

SelectUser(
        users: Optional[List[UserInfo]] = None,
        team_id: Optional[int] = None,
        roles: Optional[List[str]] = None,
        filterable: Optional[bool] = True,
        placeholder: Optional[str] = "Select user",
        size: Optional[Literal["large", "small", "mini"]] = None,
        multiple: bool = False,
        widget_id: Optional[str] = None,
)
select-user

Parameters

Parameters
Type
Description

users

Optional[List[UserInfo]]

List of UserInfo objects for team.

team_id

Optional[int]

Team ID to fetch users from if needed.

roles

Optional[List[str]]

List of allowed user roles to filter by (e.g., ['admin', 'developer']).

filterable

Optional[bool]

Enable search/filter functionality in dropdown.

placeholder

Optional[str]

Placeholder text when no user is selected.

size

Optional[Literal["large", "small", "mini"]]

Size of the select dropdown.

multiple

bool

Whether multiple selection is enabled.

widget_id

Optional[str]

Unique widget identifier.

users

Initial list of UserInfo instances from the team.

type: Optional[List[UserInfo]]

default value: None

team_id

Team ID to fetch users from if users list is not provided. When provided, users will be automatically loaded from the team.

type: Optional[int]

default value: None

roles

List of allowed user roles to filter by. Only users with these roles will be shown in the dropdown.

type: Optional[List[str]]

default value: None

filterable

Enable or disable filtering/searching functionality in the dropdown.

type: Optional[bool]

default value: True

placeholder

Set placeholder text shown when no user is selected.

type: Optional[str]

default value: "Select user"

multiple

Enable multiple user selection.

type: bool

default value: False

size

Set the size of the widget.

type: Optional[Literal["large", "small", "mini"]]

default value: None

Methods and attributes

Attributes and Methods
Description

get_selected_user()

Get the currently selected UserInfo object(s).

get_value()

Get the currently selected user login(s).

set_value()

Sets the selected user by login or list of logins.

get_all_users()

Returns a copy of all available users.

set_users()

Updates the list of available users and refreshes the widget.

set_team_id()

Load users from a team by team_id.

set_selected_users_by_ids()

Set the selected user(s) by user ID(s).

@value_changed

Decorator for value change event.

Mini App Example

You can find this example in our GitHub repository:

supervisely-ecosystem/ui-widgets-demos/selection/028_select_user/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 members

Initialize SelectUser widget

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.

Handle user selection changes

layout

Last updated

Was this helpful?