TextArea
Introduction
TextArea
widget in Supervisely is a widget that allows users to enter and edit multiple lines of text. The widget provides a large text input area that can be customized with various options, such as placeholder text, autosize or read-only properties, and default value. TextArea
widget is often used for collecting longer form input from users, such as descriptions or comments.
Function signature
TextArea(
value=None,
placeholder="Please input",
rows=2,
autosize=True,
readonly=False,
widget_id=None,
)

Parameters
value
str
Widgets text value
placeholder
str
Specifies a short hint that describes the expected value of a text area
rows
int
Specifies the visible number of lines in a text area
autosize
bool
Specifies that a text area should automatically get focus
readonly
bool
Specifies that a text area should be read-only
widget_id
str
ID of the widget
value
Widgets text value
type: str
default value: None
input_value = "Some text " * 100
text_area = TextArea(value=input_value)

placeholder
Specifies a short hint that describes the expected value of a text area.
type: str
default value: "Please input"
text_area = TextArea(placeholder="Placeholder data")

rows
Specifies the visible number of lines in a text area.
type: int
default value: 2
input_value = "Some text " * 100
text_area = TextArea(value=input_value, rows=100)

autosize
Specifies that a text area should automatically get focus.
type: bool
default value: True
text_area = TextArea(rows=10, autosize=False)

readonly
Specifies that a text area should be read-only.
type: bool
default value: false
text_area = TextArea(value="some text", readonly=True)

widget_id
ID of the widget.
type: str
default value: None
Methods and attributes
set_value(value: str)
Set value data.
get_value()
Returns input value data.
is_readonly()
Check TextArea
is readonly
or not.
enable_readonly()
Set readonly
== True
.
disable_readonly()
Set readonly
== False
.
Mini App Example
You can find this example in our Github repository:
ui-widgets-demos/text elements/002_textarea/src/main.py
Import libraries
import os
import supervisely as sly
from supervisely.app.widgets import Card, Container, TextArea, Button
from dotenv import load_dotenv
import random
import string
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()
Initialize Button
widgets we will use
Button
widgets we will usebutton_random_text = Button(text="Generate random text")
button_clean_input = Button(text="Clean input")
buttons_container = Container(
widgets=[button_random_text, button_clean_input],
direction="horizontal",
)
Initialize TextArea
widget
TextArea
widgettext_area = TextArea()
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.
card = Card(
title="TextArea",
content=Container(widgets=[text_area, buttons_container]),
)
layout = Container(widgets=[card], direction="vertical")
Create app using layout
Create an app object with layout parameter.
app = sly.Application(layout=layout)
Add functions to control widgets from python code
@button_random_text.click
def random_text():
random_text = "".join(
random.choice(string.ascii_uppercase + string.digits) for _ in range(1000)
)
text_area.set_value(value=random_text)
@button_clean_input.click
def clear():
text_area.set_value(value="")

Last updated
Was this helpful?