NotificationBox is a widget to display messages to the user. It immediately attracts the user's attention and can be used to inform the user about important events, such as the successful completion of a task, errors during execution, or the need to make adjustments to the annotation. NotificationBox supports various levels of messages, such as informational, success, warning, and error.
Function signature
note_box = NotificationBox(
title="Notification Box",
description="Lorem ipsum dolor sit amet...",
box_type="info",
widget_id=None
)
note_box_success = NotificationBox(
title="Box type: SUCCESS",
description="Lorem ipsum dolor sit amet... anim id est laborum.",
box_type="success"
)
note_box_info = NotificationBox(
title="Box type: INFO",
description="Lorem ipsum dolor sit amet... anim id est laborum.",
box_type="info"
)
note_box_warning = NotificationBox(
title="Box type: WARNING",
description="Lorem ipsum dolor sit amet... anim id est laborum.",
box_type="warning"
)
note_box_warning = NotificationBox(
title="Box type: WARNING",
description="Lorem ipsum dolor sit amet... anim id est laborum.",
box_type="warning"
)
note_box_error = NotificationBox(
title="Box type: ERROR",
description="Lorem ipsum dolor sit amet... anim id est laborum.",
box_type="error"
)
widget_id
ID of the widget.
type:str
default value:None
Methods and attributes
Attributes and Methods
Description
title
Get or set notification box title property.
description
Get or set notification box description property.
set(title: str, description: str)
Set title and description properties.
Mini App Example
You can find this example in our Github repository:
import os
from time import sleep
import supervisely as sly
from dotenv import load_dotenv
from supervisely.app.widgets import Button, Card, Container, Flexbox, NotificationBox
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 NotificationBox widget
In this tutorial we will use 4 types of notification box.
note_box_info = NotificationBox()
note_box_info.hide() # hide widget (you can show it later)
note_box_success = NotificationBox(title="Finished.", box_type="success")
note_box_success.hide()
note_box_error = NotificationBox(title="Error.", box_type="error")
note_box_error.hide()
note_box_warning = NotificationBox(title="Warning.", box_type="warning")
note_box_warning.hide()
Create app layout
For 1 example we will create project and show notication with info box type