Skip to content

notification_banner

_notification_banner

Toast/banner notification widget.

Classes:

Name Description
FXNotificationBanner

Animated pop-up notification cards that slide in from the right.

Classes

FXNotificationBanner

FXNotificationBanner(
    parent: Optional[QWidget] = None,
    message: str = "",
    severity_type: Optional[int] = None,
    timeout: int = 5000,
    action_text: Optional[str] = None,
    actions: Optional[Mapping[str, Callable[[], None]]] = None,
    closable: bool = True,
    width: int = 320,
    logger: Optional[Logger] = None,
    title: Optional[str] = None,
    icon: Optional[str] = None,
    margin: int = 16,
    spacing: int = 8,
)

Bases: FXThemeAware, QFrame


              flowchart TD
              fxgui.fxwidgets._notification_banner.FXNotificationBanner[FXNotificationBanner]
              fxgui.fxstyle.FXThemeAware[FXThemeAware]

                              fxgui.fxstyle.FXThemeAware --> fxgui.fxwidgets._notification_banner.FXNotificationBanner
                


              click fxgui.fxwidgets._notification_banner.FXNotificationBanner href "" "fxgui.fxwidgets._notification_banner.FXNotificationBanner"
              click fxgui.fxstyle.FXThemeAware href "" "fxgui.fxstyle.FXThemeAware"
            

Animated pop-up notification cards that slide in from the right.

This widget provides toast-style notifications with severity levels, auto-dismiss, and optional action buttons. Notifications automatically stack when multiple are shown and reposition when one is dismissed.

Parameters:

Name Type Description Default
parent
Optional[QWidget]

Parent widget (required for positioning).

None
message
str

The notification message.

''
severity_type
Optional[int]

Severity level (CRITICAL, ERROR, WARNING, SUCCESS, INFO, DEBUG). If None, a custom notification is shown using title and icon.

None
timeout
int

Auto-dismiss timeout in milliseconds (0 = no auto-dismiss).

5000
action_text
Optional[str]

Text for a single action button. Sugar for a one-entry actions whose callback emits action_clicked.

None
actions
Optional[Mapping[str, Callable[[], None]]]

Buttons to put on the banner, as {label: callback}, left to right. The first one is styled as the primary. A banner with actions never auto-dismisses, and clicking one runs its callback then dismisses the banner.

None
closable
bool

Whether to show a close button.

True
width
int

Fixed width of the notification card (default 320).

320
logger
Optional[Logger]

A logger object to log the message when shown. The severity level is mapped to the appropriate logging level.

None
title
Optional[str]

Custom title for the notification. Overrides severity-based title.

None
icon
Optional[str]

Custom icon name for the notification. Overrides severity-based icon.

None
margin
int

Margin from the edges of the parent widget (default 16).

16
spacing
int

Spacing between stacked notifications (default 8).

8
Signals

closed: Emitted when the banner is closed. action_clicked: Emitted when the action_text button is clicked.

Examples:

>>> # Simple notification - auto-positions and stacks
>>> banner = FXNotificationBanner(
...     parent=window,
...     message="File saved successfully!",
...     severity_type=SUCCESS,
... )
>>> banner.show()
>>>
>>> # Custom notification
>>> banner = FXNotificationBanner(
...     parent=window,
...     message="New version available!",
...     title="Update",
...     icon="system_update",
... )
>>> banner.show()
>>>
>>> # Interactive notification - waits for the artist to answer
>>> banner = FXNotificationBanner(
...     parent=window,
...     message="Publish failed on 3 shots.",
...     severity_type=ERROR,
...     actions={"Retry": retry_publish, "Open log": open_log},
... )
>>> banner.show()

Methods:

Name Description
add_action

Add an action button to the banner.

dismiss

Dismiss the notification with slide-out animation to the right.

eventFilter

Handle parent resize events to reposition notifications.

set_message

Set the notification message.

set_timeout

Set the auto-dismiss timeout.

show

Show the notification with slide-in animation from the right.

Methods:
add_action
add_action(
    text: str, callback: Optional[Callable[[], None]] = None
) -> QPushButton

Add an action button to the banner.

A banner you are meant to answer must not disappear while you reach for it, so the first action cancels auto-dismiss: the banner then stays until an action or the close button is used. Clicking an action runs callback, then dismisses the banner.

Parameters:

Name Type Description Default
text str

The button label.

required
callback Optional[Callable[[], None]]

Called when the button is clicked, before the dismiss.

None

Returns:

Name Type Description
QPushButton QPushButton

The button, for callers who want to restyle it or wire extra signals.

Examples:

>>> banner.add_action("Retry", retry_publish)
dismiss
dismiss() -> None

Dismiss the notification with slide-out animation to the right.

eventFilter
eventFilter(obj, event) -> bool

Handle parent resize events to reposition notifications.

set_message
set_message(message: str) -> None

Set the notification message.

Parameters:

Name Type Description Default
message str

The new message text.

required
set_timeout
set_timeout(timeout: int) -> None

Set the auto-dismiss timeout.

Parameters:

Name Type Description Default
timeout int

Timeout in milliseconds (0 = no auto-dismiss).

required
show
show() -> None

Show the notification with slide-in animation from the right.

Automatically calculates position based on other active notifications for the same parent widget, stacking them vertically with spacing.