Input
Introduction
Input widget in Supervisely allows to create input fields for text. It is a useful widget for applications that require users to enter text, such as project name, dataset name or path to folder or archive with data.
The Input widget also allows you to set default text to be displayed in the input field, set text placeholder, set input field to be readonly, and set a minimum and maximum length for the input.
Function signature
Input(
value="",
minlength=0,
maxlength=1000,
placeholder="",
size=None,
readonly=False,
widget_id=None
)
Parameters
value
str
Binding value
minlength
int
Minimum input text length
maxlength
int
Maximum input text length
placeholder
str
Placeholder of input
size
Literal["mini", "small", "large", None]
Size of input
readonly
bool
Same as readonly in native input
type
Literal["text", "password"]
Same as type in native input
icon
Literal["search", "edit"]
Set an icon to indicate input type
widget_id
str
ID of the widget
value
Binding value.
type: str
default value: ""

minlength
Minimum input text length.
type: int
default value: 0
maxlength
Maximum input text length.
type: int
default value: 1000
placeholder
Placeholder of input.
type: str
default value: ""

size
Size of input.
type: Literal["mini", "small", "large", None]
default value: None

readonly
Same as readonly in native input.
type: bool
default value: false
type
Same as type in native input.
type: Literal["text", "password"]
default value: None

icon
Set an icon to indicate input type. Set to None to disable icon.
type: Literal["search", "edit"]
default value: None
widget_id
ID of the widget.
type: str
default value: None
Methods and attributes
is_readonly()
Return True if input is readonly, else False.
set_value(value: str)
Set input value.
get_value()
Get input value.
enable_readonly()
Enable input`s readonly property.
disable_readonly()
Disable input`s readonly property.
set_icon()
Set icon type: "edit" or "search".
@value_changed
Decorator functions is handled when input value is changed.
Mini App Example
You can find this example in our Github repository:
ui-widgets-demos/input/001_input/src/main.py
Import libraries
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Initialize Input widget
Input widgetCreate buttons to control Input widget values.
Input widget values.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 app using layout
Create an app object with layout parameter.
Add functions to control widget from python code

Last updated
Was this helpful?