Supervisely
About SuperviselyEcosystemContact usSlack
  • 💻Supervisely Developer Portal
  • 🎉Getting Started
    • Installation
    • Basics of authentication
    • Intro to Python SDK
    • Environment variables
    • Supervisely annotation format
      • Project Structure
      • Project Meta: Classes, Tags, Settings
      • Objects
      • Tags
      • Image Annotation
      • Video Annotation
      • Point Clouds Annotation
      • Point Cloud Episode Annotation
      • Volumes Annotation
    • Python SDK tutorials
      • Images
        • Images
        • Image and object tags
        • Spatial labels on images
        • Keypoints (skeletons)
        • Multispectral images
        • Multiview images
        • Advanced: Optimized Import
        • Advanced: Export
      • Videos
        • Videos
        • Video and object tags
        • Spatial labels on videos
      • Point Clouds
        • Point Clouds (LiDAR)
        • Point Cloud Episodes and object tags
        • 3D point cloud object segmentation based on sensor fusion and 2D mask guidance
        • 3D segmentation masks projection on 2D photo context image
      • Volumes
        • Volumes (DICOM)
        • Spatial labels on volumes
      • Common
        • Iterate over a project
        • Iterate over a local project
        • Progress Bar tqdm
        • Cloning projects for development
    • Command Line Interface (CLI)
      • Enterprise CLI Tool
        • Instance administration
        • Workflow automation
      • Supervisely SDK CLI
    • Connect your computer
      • Linux
      • Windows WSL
      • Troubleshooting
  • 🔥App development
    • Basics
      • Create app from any py-script
      • Configuration file
        • config.json
        • Example 1. Headless
        • Example 2. App with GUI
        • v1 - Legacy
          • Example 1. v1 Modal Window
          • Example 2. v1 app with GUI
      • Add private app
      • Add public app
      • App Compatibility
    • Apps with GUI
      • Hello World!
      • App in the Image Labeling Tool
      • App in the Video Labeling Tool
      • In-browser app in the Labeling Tool
    • Custom import app
      • Overview
      • From template - simple
      • From scratch - simple
      • From scratch GUI - advanced
      • Finding directories with specific markers
    • Custom export app
      • Overview
      • From template - simple
      • From scratch - advanced
    • Neural Network integration
      • Overview
      • Serving App
        • Introduction
        • Instance segmentation
        • Object detection
        • Semantic segmentation
        • Pose estimation
        • Point tracking
        • Object tracking
        • Mask tracking
        • Image matting
        • How to customize model inference
        • Example: Custom model inference with probability maps
      • Serving App with GUI
        • Introduction
        • How to use default GUI template
        • Default GUI template customization
        • How to create custom user interface
      • Inference API
      • Training App
        • Overview
        • Tensorboard template
        • Object detection
      • High level scheme
      • Custom inference pipeline
      • Train and predict automation model pipeline
    • Advanced
      • Advanced debugging
      • How to make your own widget
      • Tutorial - App Engine v1
        • Chapter 1 Headless
          • Part 1 — Hello world! [From your Python script to Supervisely APP]
          • Part 2 — Errors handling [Catching all bugs]
          • Part 3 — Site Packages [Customize your app]
          • Part 4 — SDK Preview [Lemons counter app]
          • Part 5 — Integrate custom tracker into Videos Annotator tool [OpenCV Tracker]
        • Chapter 2 Modal Window
          • Part 1 — Modal window [What is it?]
          • Part 2 — States and Widgets [Customize modal window]
        • Chapter 3 UI
          • Part 1 — While True Script [It's all what you need]
          • Part 2 — UI Rendering [Simplest UI Application]
          • Part 3 — APP Handlers [Handle Events and Errors]
          • Part 4 — State and Data [Mutable Fields]
          • Part 5 — Styling your app [Customizing the UI]
        • Chapter 4 Additionals
          • Part 1 — Remote Developing with PyCharm [Docker SSH Server]
      • Custom Configuration
        • Fixing SSL Certificate Errors in Supervisely
        • Fixing 400 HTTP errors when using HTTP instead of HTTPS
      • Autostart
      • Coordinate System
      • MLOps Workflow integration
    • Widgets
      • Input
        • Input
        • InputNumber
        • InputTag
        • BindedInputNumber
        • DatePicker
        • DateTimePicker
        • ColorPicker
        • TimePicker
        • ClassesMapping
        • ClassesColorMapping
      • Controls
        • Button
        • Checkbox
        • RadioGroup
        • Switch
        • Slider
        • TrainValSplits
        • FileStorageUpload
        • Timeline
        • Pagination
      • Text Elements
        • Text
        • TextArea
        • Editor
        • Copy to Clipboard
        • Markdown
        • Tooltip
        • ElementTag
        • ElementTagsList
      • Media
        • Image
        • LabeledImage
        • GridGallery
        • Video
        • VideoPlayer
        • ImagePairSequence
        • Icons
        • ObjectClassView
        • ObjectClassesList
        • ImageSlider
        • Carousel
        • TagMetaView
        • TagMetasList
        • ImageAnnotationPreview
        • ClassesMappingPreview
        • ClassesListPreview
        • TagsListPreview
        • MembersListPreview
      • Selection
        • Select
        • SelectTeam
        • SelectWorkspace
        • SelectProject
        • SelectDataset
        • SelectItem
        • SelectTagMeta
        • SelectAppSession
        • SelectString
        • Transfer
        • DestinationProject
        • TeamFilesSelector
        • FileViewer
        • Dropdown
        • Cascader
        • ClassesListSelector
        • TagsListSelector
        • MembersListSelector
        • TreeSelect
        • SelectCudaDevice
      • Thumbnails
        • ProjectThumbnail
        • DatasetThumbnail
        • VideoThumbnail
        • FolderThumbnail
        • FileThumbnail
      • Status Elements
        • Progress
        • NotificationBox
        • DoneLabel
        • DialogMessage
        • TaskLogs
        • Badge
        • ModelInfo
        • Rate
        • CircleProgress
      • Layouts and Containers
        • Card
        • Container
        • Empty
        • Field
        • Flexbox
        • Grid
        • Menu
        • OneOf
        • Sidebar
        • Stepper
        • RadioTabs
        • Tabs
        • TabsDynamic
        • ReloadableArea
        • Collapse
        • Dialog
        • IFrame
      • Tables
        • Table
        • ClassicTable
        • RadioTable
        • ClassesTable
        • RandomSplitsTable
        • FastTable
      • Charts and Plots
        • LineChart
        • GridChart
        • HeatmapChart
        • ApexChart
        • ConfusionMatrix
        • LinePlot
        • GridPlot
        • ScatterChart
        • TreemapChart
        • PieChart
      • Compare Data
        • MatchDatasets
        • MatchTagMetas
        • MatchObjClasses
        • ClassBalance
        • CompareAnnotations
      • Widgets demos on github
  • 😎Advanced user guide
    • Objects binding
    • Automate with Python SDK & API
      • Start and stop app
      • User management
      • Labeling Jobs
  • 🖥️UI widgets
    • Element UI library
    • Supervisely UI widgets
    • Apexcharts - modern & interactive charts
    • Plotly graphing library
  • 📚API References
    • REST API Reference
    • Python SDK Reference
Powered by GitBook
On this page
  • Introduction
  • Function signature
  • Parameters
  • text
  • button_type
  • button_size
  • plain
  • show_loading
  • icon
  • icon_gap
  • emit_on_click
  • style
  • call_on_click
  • widget_id
  • Mini App Example
  • Init API client
  • Initialize Button and Text widgets
  • Create app layout
  • Create app using layout
  • Handle button clicks

Was this helpful?

Edit on GitHub
  1. App development
  2. Widgets
  3. Controls

Button

PreviousControlsNextCheckbox

Last updated 1 year ago

Was this helpful?

Introduction

Button widget in Supervisely is a user interface element that allows users to create clickable buttons in the appliactions. These buttons can be customized with text, size, colors, and icons, and can be used to trigger specific actions or workflows. The Button widget is a versatile tool that can help users automate repetitive tasks or streamline their workflows, making it a valuable addition to any project dashboard.

Function signature

Button(
    text="Button",
    button_type="primary",
    button_size=None,
    plain=False,
    show_loading=True,
    icon=None,
    icon_gap=5,
    widget_id=None,
)

Parameters

Parameters
Type
Description

text

str

Determine text that displayed on the button

button_type

Literal["primary", "info", "warning", "danger", "success", "text"]

Button type

button_size

Literal["mini", "small", "large", None]

Button size

plain

bool

Determine whether button is a plain button

show_loading

bool

If True display loading animation when loading property is True

icon

str

Button icon, accepts an icon name of icon from Material Design Iconic Font library

icon_gap

int

Gap between icon and button text

emit_on_click

str

Emit an event on click

call_on_click

str

Call JavaScript function on click

widget_id

str

ID of the widget

text

Determine text that will be displayed on the button.

type: str

default value: Button

button = Button(text="My text on the button")

button_type

Button type.

type: Literal["primary", "info", "warning", "danger", "success", "text"]

default value: "primary"

button_primary = Button(text="primary", button_type="primary")
button_info = Button(text="info", button_type="info")
button_warning = Button(text="warning", button_type="warning")
button_danger = Button(text="danger", button_type="danger")
button_success = Button(text="success", button_type="success")
button_text = Button(text="text", button_type="text")

button_size

Button size.

type: Literal["mini", "small", "large", None]

default value: None

button_mini = Button(text="mini", button_size="mini")
button_small = Button(text="small", button_size="small")
button_large = Button(text="large", button_size="large")

plain

Determine whether button is a plain button.

type: bool

default value: False

button_plain = Button(plain=True)

show_loading

Determine whether button is loading.

type: bool

default value: False

button_1 = Button(show_loading=False)

button_2 = Button(show_loading=True)

icon

type: str

default value: None

button_icon = Button(text="icon", icon="zmdi zmdi-play")

icon_gap

Gap between icon and button text.

type: int

default value: 5

button_icon_gap_5 = Button(text="icon gap 5", icon="zmdi zmdi-play", icon_gap=5)
button_icon_gap_50 = Button(text="icon gap 50", icon="zmdi zmdi-play", icon_gap=50)

emit_on_click

Emit an event on click

type: str

default value: ""

button = Button(text="Open Sidebar", emit_on_click="openSidebar")

style

Specifies an inline style for an element.

type: str

default value: ""

button = button("OK", style="padding: 5px;")

call_on_click

Call JavaScript function on click.

type: str

default value: ""

button = Button(text="Save", call_on_click="closeSidebar();")

widget_id

ID of the widget.

type: str

default value: None

Mini App Example

You can find this example in our Github repository:

import os
import supervisely as sly
from dotenv import load_dotenv
from supervisely.app.widgets import Button, Card, Container, Text

Init API client

Init API for communicating with Supervisely Instance. First, we load environment variables with credentials:

load_dotenv("local.env")
load_dotenv(os.path.expanduser("~/supervisely.env"))
api = sly.Api()

Initialize Button and Text widgets

button_add = Button(text="Add", icon="zmdi zmdi-plus-1")
button_subtract = Button(text="Subtract", icon="zmdi zmdi-neg-1")
text_num = Text(text="0", status="text")

Create app layout

Prepare a layout for app using Card widget with the content parameter and place 3 widgets that we've just created in the Container widget. Place order in the Container is important, we want buttons to be displayed above Text widget.

card = Card(
    "Button",
    description="👉 Click on the button to add or subtract 1",
    content=Container([button_add, button_subtract, text_num]),
)
layout = Container(widgets=[card], direction="vertical")

Create app using layout

Create an app object with layout parameter.

app = sly.Application(layout=layout)

Our app layout is ready. It's time to handle button clicks.

Handle button clicks

Use the decorator as shown below to handle button click. We have 2 buttons, one for adding and another one for subtracting

@button_add.click
def add():
    text_num.text = str(int(text_num.text) + 1)

@button_subtract.click
def subtract():
    text_num.text = str(int(text_num.text) - 1)

Button icon, accepts an icon name of icon component. Icons can be found at .

Open any icon at and copy it's name (see example below).

🔥
zavoloklom.github.io
zavoloklom.github.io
ui-widgets-demos/controls/001_button/src/main.py