ProjectThumbnail

Introduction

ProjectThumbnail widget in Supervisely is a widget that allows to display a thumbnail image that represents supervisely project. It is a useful widget for applications that run from specific project, allowing users to have quick access to this project, so that when the user clicks on the thumbnail, the link will take him to this project.

Function signature

ProjectThumbnail(info=None, widget_id=None)

Parameters

ParametersTypeDescription

info

ProjectInfo

NamedTuple, containing information about project

remove_margins

bool

Set margins to 0 to make widget more compact

widget_id

str

ID of the widget

info

NamedTuple, containing information about project.

type: ProjectInfo

default value: None

project = api.project.get_info_by_id(project_id)
project_thumbnail = ProjectThumbnail(project)

remove_margins

Set margins to 0 to make widget more compact.

type: bool

default value: False

project_thumbnail = ProjectThumbnail(project, remove_margins=True)

widget_id

ID of the widget.

type: str

default value: None

Methods and attributes

Attributes and MethodsDescription

set(info: ProjectInfo)

Set input project data.

Mini App Example

You can find this example in our Github repository:

ui-widgets-demos/thumbnail/001_project_thumbnail/src/main.py

Import libraries

import os

import supervisely as sly
from dotenv import load_dotenv
from supervisely.app.widgets import Card, Container, ProjectThumbnail

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()

Get Project ID and info

project_id = sly.env.project_id()
project = api.project.get_info_by_id(project_id)

Initialize ProjectThumbnail widget

project_thumbnail = ProjectThumbnail(project)

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.

# create new cards
card = Card(
    title="Project Thumbnail",
    content=Container(widgets=[project_thumbnail]),
)

layout = Container(widgets=[card])

Create app using layout

Create an app object with layout parameter.

app = sly.Application(layout=layout)

Last updated