ImageSlider
Introduction
ImageSlider widget in Supervisely is a simple widget that displays images using Slider and is convenient to use when there is no need to add extra functions for displaying annotations or adjusting their settings, but only to display the images passed to it by a list of URLs or local paths.
Function signature
ImageSlider(
previews=None,
examples=None,
combined_data=None,
height=200,
selectable=False,
preview_idx=None,
preview_url=None,
widget_id=None,
)Parameters
previews
List[str]
List of previews URLs for the Slider widget
examples
List[List[str]]
List of image examples for the Slider widget
combined_data
List[dict]
List of image previews and examples URLs for the Slider widget
height
int
Height of the Slider widget
selectable
bool
Determines whether image selection is enabled or disabled
preview_idx
int
Index of the initially selected image in Slider
preview_url
str
URL of the initially selected image in Slider
widget_id
str
ID of the widget
previews
List of previews URLs for the Slider widget.
type: List[str]
default value: None
examples
List of image examples for the Slider widget.
type: List[List[str]]
default value: None
combined_data
List of image previews and examples URLs for the Slider widget.
type: List[dict]
default value: None
height
Height of the Slider widget.
type: int
default value: 200

selectable
Determines whether image selection is enabled or disabled.
type: bool
default value: False

preview_idx
Index of the initially selected image in Slider. Use only if selectable is True.
type: int
default value: None
preview_url
URL of the initially selected image in Slider. Use only if selectable is True.
type: str
default value: None
widget_id
ID of the widget.
type: str
default value: None
get_selected_preview()
Get URL of the selected image in the slider.
set_selected_preview(value: str)
Sets URL of the image to be displayed as the preview image in the slider.
get_selected_idx()
Retrieves the index of the currently selected image in the slider.
set_selected_idx(value: int)
Sets the index of the image to be displayed as the preview image in the slider.
get_selected_examples()
Retrieves the list of URLs of the currently selected image examples in the slider.
is_selectable
Returns a boolean indicating whether image selection is enabled or disabled.
enable_selection()
Enables image selection.
disable_selection()
Disables image selection.
get_data_length()
Retrieves the length of the image URL list.
get_data()
Retrieves the list of image URLs and examples.
set_data(previews: List[str], examples: List[List[str]], combined_data: List[dict])
Sets the list of image URLs and examples.
append_data(previews: List[str], examples: List[List[str]], combined_data: List[dict])
Extends the list of image URLs and examples.
Mini App Example
You can find this example in our GitHub repository:
supervisely-ecosystem/ui-widgets-demos/media/011_image_slider/src/main.py
Init API client
Init API for communicating with Supervisely Instance. First, we load environment variables with credentials:
Prepare data for ImageSlider widget
ImageSlider widgetInitialize ImageSlider widget
ImageSlider widgetInitialize Text, Editor and Button widgets, we will use
Text, Editor and Button widgets, we will useCreate app layout
Prepare a layout for the app using Card widget with the content parameter and place widgets that we've just created in the Container widget. Place order in the Container is important, we want buttons to be displayed above the Text widget.
Create an app using the layout
Create an app object with the layout parameter.
Our app layout is ready. It's time to handle button clicks.
Add functions to control widgets from python code
Last updated
Was this helpful?