Modal

Introduction

Modal widget in Supervisely displays content in a modal overlay window with customizable size and content. It can contain any other widgets and provides programmatic control to show/hide the modal. The modal also supports callbacks to track when it opens or closes.

Read this tutorial in developer portal.

Function signature

Modal(
    title="My Modal",
    widgets=[text_widget, input_widget],
    size="small",
    widget_id=None,
)
modal

Parameters

Parameters
Type
Description

title

str

Modal window title

widgets

List[Widget]

Widgets to display in modal

size

Literal["tiny", "small", "large", "full"]

Modal size

widget_id

str

ID of the widget

title

Modal window title displayed at the top of the modal.

type: str

default value: ""

widgets

List of widgets to be displayed inside the modal. Can contain any Supervisely widgets.

type: List[Widget]

default value: []

size

Size of the modal window. Available options: "tiny", "small", "large", "full".

type: Literal["tiny", "small", "large", "full"]

default value: "small"

widget_id

ID of the widget.

type: str

default value: None

Methods and attributes

Methods
Description

show()

Shows the modal window.

hide()

Hides the modal window.

show_modal()

Shows the modal (alias for show).

close_modal()

Closes the modal (alias for hide).

is_opened()

Returns True if modal is currently open.

@value_changed()

Decorator to handle modal visibility changes (open/close).

title

Property to get/set the modal title.

widgets

Property to get/set the list of widgets.

Mini App Example

You can find this example in our Github repository:

supervisely-ecosystem/ui-widgets-demos/layouts-and-containers/018_modal/src/main.py

Import libraries

Init API client

First, we load environment variables with credentials and init API for communicating with Supervisely Instance:

Initialize widgets to display inside modal

Initialize Modal widget

Show modal

Create app using layout

Create an app object with layout parameter.

Add button click handler to open modal

Add value changed callback to track modal state

Last updated

Was this helpful?