Skip to content

Count badge

A round counter for notifications or problems. Above max it shows 99+.

ui.count_badge · Category: Feedback · Full reference →

Count badgeCount badge
  • Next to an icon or tab to show how many unread items or errors there are.
  • For text statuses use a Badge.
import pyzed as pz
from pyzed import ui
pz.row([
ui.count_badge(3),
ui.count_badge(42, tint="success"),
ui.count_badge(120, tint="error"),
pz.row([ui.icon_button("bell", on_press), ui.count_badge(7)], spacing=2, align="center"),
], spacing=16, align="center")

Above max it shows max+.

Count badge: 3Count badge: 3
3
Code
ui.count_badge(3)
Count badge: 42Count badge: 42
42
Code
ui.count_badge(42)
Count badge: 120Count badge: 120
120
Code
ui.count_badge(120)
Count badge: max=9Count badge: max=9
max=9
Code
ui.count_badge(12, max=9)
Count badge: tint="success"Count badge: tint="success"
tint="success"
Code
ui.count_badge(5, tint="success")
Count badge: tint="warning"Count badge: tint="warning"
tint="warning"
Code
ui.count_badge(5, tint="warning")
Count badge: tint="error"Count badge: tint="error"
tint="error"
Code
ui.count_badge(5, tint="error")
Count badge: NotificationsCount badge: Notifications
Notifications
Code
pz.row([ui.icon_button("bell", on_press), ui.count_badge(7)], spacing=2, align="center")

With show_zero=False it draws nothing at 0 but keeps its place in the layout.

Count badge: show_zero=FalseCount badge: show_zero=False
show_zero=False
Code
pz.row([ui.icon_button("bell", on_press), ui.count_badge(0, show_zero=False)], align="center")

Count badge has no events of its own: it shows what you give it. Like every widget it also has the 18 common events (click, double_click, right_click, mouse_enter, drag, key_down, resize…), attached with .on(...): see Events and Events of every component.

count_badge(count, *, tint='accent', max=99, show_zero=True, theme=None)

A round counter (notifications, problems…). Shows 99+ above max.

Property Default Description
count required The number.
tint "accent" Semantic color: "accent", "error", "warning", "success", "info" or a token.
max 99 Maximum before showing N+.
show_zero True With False, a count of 0 draws nothing.
theme None Theme to use instead of the current one (pyzed.theme.current()).

Full reference →