SelectTeam widget in Supervisely is a dropdown menu that allows users to select a team from a list of available teams. Clicking on it can be processed from python code. This widget is particularly useful when working with multiple teams in Supervisely and allows to easily switch between team in applications.
import os
import supervisely as sly
from dotenv import load_dotenv
from supervisely.app.widgets import Button, Card, Container, NotificationBox, SelectTeam
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
load_dotenv("local.env")
load_dotenv(os.path.expanduser("~/supervisely.env"))
api = sly.Api()
Prepare Team ID
team_id = sly.env.team_id()
Initialize SelectTeam widget
select_team = SelectTeam()
Create button and notification box we will use in UI for demo
@ok_btn.click
def show_team_members():
team_id = select_team.get_selected_id()
team = api.team.get_info_by_id(team_id)
notification_box.set(
title=f"Team '{team.name}'",
description=f"Your role in the team: {team.role}",
)