badge
pdwidgets.widgets.badge
Status badge widget.
Badge(parent, x=0, y=0, w=None, h=None, align=None, align_to=None, fg=None, bg=None, visible=True, value=None, padding=None, size=12)
Bases: Widget
Small status dot or rounded count pill.
Initialize a Badge: a small colored status dot or count pill.
With no value the badge is a filled dot (useful as a connection or
status indicator); with a short value (e.g. a notification count) it
becomes a rounded pill containing the text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
Widget
|
The parent widget or screen that contains this badge. |
required |
x
|
int
|
The x-coordinate of the badge. |
0
|
y
|
int
|
The y-coordinate of the badge. |
0
|
w
|
int
|
The width of the badge (auto-sized when omitted). |
None
|
h
|
int
|
The height of the badge (auto-sized when omitted). |
None
|
align
|
int
|
The alignment of the badge. |
None
|
align_to
|
Widget
|
The widget to align to. |
None
|
fg
|
int
|
The text color; defaults to |
None
|
bg
|
int
|
The badge color; defaults to |
None
|
visible
|
bool
|
The visibility of the badge. |
True
|
value
|
Any
|
Optional short text/count; |
None
|
padding
|
tuple
|
The padding on each side of the badge. |
None
|
size
|
int
|
Diameter (dot) or height (pill) in pixels (default 12). |
12
|
Usage
online = Badge(bar, bg=screen.color_theme.success) # status dot unread = Badge(icon, value=3, align=pd.ALIGN.OUTER_TOP_RIGHT) # pill
draw(_=None)
Draw the badge as a dot (no value) or a rounded pill (with text).