ReloadableArea
Introduction
ReloadableArea
widget in Supervisely is a tool that allows dynamically creating and changing widgets in the application UI without reloading the whole page. It can be used to create a dynamic UI that changes depending on user actions without any noticeable delays.
Function signature
Parameters
Parameters | Type | Description |
---|---|---|
|
| Widget to be displayed in the area. |
|
| ID of the widget |
content
Determine the Widget
to be displayed in the ReloadableArea.
type: Widget
default value: None
Prepare widgets and put them into a container:
Initialize the ReloadableArea with the container:
widget_id
The ID of the widget.
type: str
default value: None
Initialize widget with ID:
Methods and attributes
Methods and attributes | Description |
---|---|
| Replaces content of the ReloadableArea with new widget |
| Reloads the content of the ReloadableArea widget in UI |
Mini app example
You can find this example in our GitHub repository:
supervisely-ecosystem/ui-widgets-demos/layouts_and_containers/014_reloadable_area/src/main.py
Import libraries
We're importing all those widgets just to use them in the demonstration of ReloadableArea.
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Preparing widgets for app initialization
Initialize ReloadableArea
Adding event handlers for buttons to add and remove widgets
This event will be triggered when the user clicks the Add widget
button. The random widget will be chosen from the list and added to the UI.
This event will be triggered when the user clicks the Remove widget
button. The last widget in the list will be removed from the UI. In both cases, we need to use the .reload()
method of ReloadableArea
to show the changes in the UI.
Create an app using the layout
Prepare a layout for the app using Card
widget with the content
parameter. Then create an app object with the layout parameter.
Last updated