Empty

Introduction

Empty widget is a simple placeholder widget that can be used to create empty spaces within a layout.

It has no content or functionality of its own and is typically used to provide spacing or alignment within a larger widget or layout. This widget is particularly useful for creating clean, organized interfaces with clearly defined sections and layouts.

Function signature

empty = Empty(widget_id=None)

Parameters

Parameters
Type
Description

style

str

Specifies an inline style for an element

widget_id

str

ID of the widget

style

Specifies an inline style for an element.

type: str

default value: ""

empty = Empty(style="padding: 5px;")

widget_id

ID of the widget.

type: str

default value: None

Mini App Example

You can find this example in our Github repository:

ui-widgets-demos/layouts and containers/003_empty/src/main.py

Import libraries

import os

import supervisely as sly
from dotenv import load_dotenv
from supervisely.app.widgets import Card, Container, Empty, OneOf, Select, Text

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 Empty widget

empty = Empty()

Prepare some widgets

This widget is useful in other widgets, for example, Select.Item

text = Text("Some text")
items = [
    Select.Item("item_1", content=Empty()),
    Select.Item("item_2", content=text)
]
select = Select(items=items)
one_of = OneOf(select)

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="Empty",
    content=empty,
)
layout = Container(widgets=[select, one_of])

Create app using layout

Create an app object with layout parameter.

app = sly.Application(layout=layout)

In this video demonstrated Empty (invisible) and Text widgets that we used in Select widget.

Last updated