CopyToClipboard widget allows you to wrap your widgets (Editor, Text, TextArea, or Input) and str text with a copy button. This enables you to easily obtain the value of the wrapped content and copy it to your clipboard.
Function signature
CopyToClipboard(
content="",
widget_id=None
)
default
Parameters
Parameters
Type
Description
content
Union[Editor, Text, TextArea, Input, str]
CopyToClipboard content
widget_id
str
Id of the widget
content
Determine input CopyToClipboard content.
type:Union[Editor, Text, TextArea, Input, str]
default value:""
copy_to_clipboard = CopyToClipboard(content="Some text to copy")
widget_id
ID of the widget.
type:str
default value:None
Methods and attributes
Attributes and Methods
Description
get_content()
Return wrapped content (i.e. widget or str)
Mini App Example
You can find this example in our Github repository:
Import libraries
import os
import supervisely as sly
from dotenv import load_dotenv
from supervisely.app.widgets import (
Card,
Container,
CopyToClipboard,
Editor,
Text,
TextArea,
Input,
)
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()