Rate
Introduction
Rate widget in Supervisely that allows users to provide a rating using a graphical interface. It provides a customizable rating scale and supports features like disabling the widget, allowing half ratings, and displaying text labels.
Function signature
Rate(
value=None,
max=5,
disabled=False,
allow_half=False,
texts=[],
show_text=False,
text_color="#1F2D3D",
text_template="",
colors=["#F7BA2A", "#F7BA2A", "#F7BA2A"],
void_color="#C6D1DE",
disabled_void_color="#EFF2F7",
widget_id=None,
)
Parameters
value
Union[int, float]
Rating score
max
int
Max rating score
disabled
bool
Whether Rate is read-only
allow_half
bool
Whether picking half start is allowed
texts
List[str]
Text array
show_text
bool
Whether to display texts
text_color
str
Color of texts
text_template
str
Text template when the component is read-only
colors
List[str]
Color array for icons
void_color
str
Color of unselected icons
disabled_void_color
str
Color of unselected read-only icons
widget_id
str
ID of the widget
max
Determine max rating score.
type: int
default value: 5

colors
Determine color array for icons. It should have 3 elements, each of which corresponds with a score level
type: List[str]
default value: ["#F7BA2A", "#F7BA2A", "#F7BA2A"]

disabled
Determine whether Rate is read-only.
type: bool
default value: False

allow_half
Determine whether picking half start is allowed.
type: bool
default value: False

texts
Determine text array for each star. Available if show_text is True
type: List[str]
default value: []
show_text
Determine whether to display texts.
type: bool
default value: False

text_color
Determine color of texts.
type: str
default value: "#1F2D3D"

void_color
Determine color of unselected icons.
type: str
default value: "#C6D1DE"

disabled_void_color
Determine color of unselected read-only icons.
type: str
default value: "#C6D1DE"

Methods and attributes
is_disabled
Property return True if Rate is read-only.
get_value()
Get Rate score value.
set_value(value: Union[int, float])
Set Rate score value.
get_max_value()
Get max rating score.
set_max_value(value: int)
Set max rating score.
get_colors()
Get color array for icons.
set_colors()
Set color array for icons.
disable()
Enable rate`s read-only property.
enable()
Disable rate`s read-only property.
allow_half_precision()
Enable picking half star.
disallow_half_precision()
Disable picking half star.
get_texts()
Return text array for each star.
set_texts(value: List[str])
Set text for each star.
show_text()
Enable displaying texts.
hide_text()
Disable displaying texts.
get_text_color()
Get color of texts.
set_text_color(value: str)
Set color of texts.
get_void_color()
Get color of unselected icons.
set_void_color(value: str)
Set color of unselected icons.
get_disabled_void_color()
Get color of unselected read-only icons.
set_disabled_void_color(value: str)
Set color of unselected read-only icons.
value_changed(func)
Decorator function is handled when input Rate is changed.
Mini App Example
You can find this examples in our Github repository:
supervisely-ecosystem/ui-widgets-demos/status-elements/008_rate/src/main.py
Import libraries
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
In this guide, let's look at 3 examples of using the widget Rate in the one app.
Example 1
Initialize Rate widget
Prepare InputNumber, Button and Card widgets we will use in this example
Add functions to control widgets from python code
Create app
Prepare a layout for app using Card widget with the content parameter.
Create an app object with layout parameter.
Example 2
Initialize Rate widget
Prepare InputNumber, Button and Card widgets we will use in this example
Add functions to control widgets from python code
Create app
Prepare a layout for app using Card widget with the content parameter.
Create an app object with layout parameter.
Example 3
Initialize Rate widget
Prepare Input, Field, Text, Button and Card widgets we will use in this example
Add functions to control widgets from python code
Create app
Prepare a layout for app using Card widget with the content parameter.
Create an app object with layout parameter.
Last updated
Was this helpful?