TabsDynamic

Introduction

TabsDynamic is a versatile widget in Supervisely that allows users to display and edit YAML files within their info, such as NN model settings. The widget can divide the YAML file into separate tabs, making it easier to navigate and manage complex data structures. Additionally, users can edit the YAML directly within the widget and obtain a merged YAML file with their changes. TabsDynamic also enables users to get or set the active tab from code.

Function signature

TabsDynamic(
    filepath_or_raw_yaml,
    type="border-card",
    disabled=False,
    widget_id=None,
)

Parameters

ParametersTypeDescription

filepath_or_raw_yaml

str

Path to yaml file or string

type

Literal["card", "border-card"]

Determine style of widget tabs

disabled

bool

Disable widget

widget_id

str

ID of the widget

filepath_or_raw_yaml

Determine path to yaml input file or string.

type: str

yaml_path = "layouts and containers/013_tabs_dynamic/yaml/file_1.yaml"
tabs_dynamic = TabsDynamic(yaml_path)

type

Determine style of widget tabs.

type: Literal["card", "border-card"]

default value: border-card

yaml_path = "layouts and containers/013_tabs_dynamic/yaml/file_1.yaml"
tabs_dynamic = TabsDynamic(yaml_path, type="card")
yaml_path = "layouts and containers/013_tabs_dynamic/yaml/file_1.yaml"
tabs_dynamic = TabsDynamic(yaml_path, type="border-card")

disabled

Disable widget.

type: bool

default value: false

yaml_path = "layouts and containers/013_tabs_dynamic/yaml/file_1.yaml"
tabs_dynamic = TabsDynamic(yaml_path, disabled=True)

widget_id

ID of the widget.

type: str

default value: None

Methods and attributes

Attributes and MethodsDescription

set_active_tab()

Set active tab.

get_active_tab()

Return active tab.

get_merged_yaml()

Return merged yaml.

disable()

Disable widget.

enable()

Enable widget.

Mini App Example

You can find this example in our Github repository:

ui-widgets-demos/layouts and containers/013_tabs_dynamic/src/main.py

Import libraries

import os

import supervisely as sly
from dotenv import load_dotenv
from supervisely.app.widgets import Card, Container, TabsDynamic

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

yaml_path = "layouts and containers/013_tabs_dynamic/yaml/file_1.yaml"
tabs_dynamic = TabsDynamic(yaml_path)

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="TabsDynamic", content=Container([tabs_dynamic]))
layout = Container(widgets=[card])

Create app using layout

Create an app object with layout parameter.

app = sly.Application(layout=layout)

Last updated