Skip to content

Notification Banner

A notification banner widget for displaying alerts and messages.

Preview

FXNotificationBanner

FXNotificationBanner

Bases: FXThemeAware, QFrame

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 the optional action button.

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 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()

Methods:

Name Description
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.

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.