/
main.py
50 lines (40 loc) · 1.3 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
import supervisely as sly
from dotenv import load_dotenv
from supervisely.app.widgets import Card, Container, RadioTabs, Text
# for convenient debug, has no effect in production
load_dotenv("local.env")
load_dotenv(os.path.expanduser("~/supervisely.env"))
api = sly.Api()
# initialize widgets we will use in UI
tabs = RadioTabs(
titles=["Info tab", "Success tab", "Warning tab", "Error tab"],
contents=[
Text("Info text", status="info"),
Text("Success text", status="success"),
Text("Warning text", status="warning"),
Text("Error text", status="error"),
],
descriptions=[
"Tab with info text",
"Tab with success text",
"Tab with warning text",
"Tab with error text",
],
)
many_tabs = RadioTabs(
titles=[f"{i + 1} tab" for i in range(10)],
contents=[Text(f"{i + 1} text", status="info") for i in range(10)],
descriptions=[f"Tab with {i + 1} text" for i in range(10)],
)
text = Text("Opened tab: Info tab")
card = Card(
title="Radio tabs",
content=Container([tabs, text]),
)
card_many_tabs = Card("Many radio tabs", content=many_tabs)
layout = Container(widgets=[card, card_many_tabs])
app = sly.Application(layout=layout)
@tabs.value_changed
def show_opened_tab(value):
text.text = f"Opened tab: {value}"