Notification Banner¶
A notification banner widget for displaying alerts and messages.
Preview
FXNotificationBanner
¶
Bases: ,
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 widget (required for positioning). |
None
|
|
|
The notification message. |
''
|
|
|
Severity level (CRITICAL, ERROR, WARNING, SUCCESS, INFO, DEBUG). If None, a custom notification is shown using title and icon. |
None
|
|
|
Auto-dismiss timeout in milliseconds (0 = no auto-dismiss). |
5000
|
|
|
Text for the optional action button. |
None
|
|
|
Whether to show a close button. |
True
|
|
|
Fixed width of the notification card (default 320). |
320
|
|
|
A logger object to log the message when shown. The severity level is mapped to the appropriate logging level. |
None
|
|
|
Custom title for the notification. Overrides severity-based title. |
None
|
|
|
Custom icon name for the notification. Overrides severity-based icon. |
None
|
|
|
Margin from the edges of the parent widget (default 16). |
16
|
|
|
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 the notification with slide-out animation to the right. |
|
Handle parent resize events to reposition notifications. |
|
Set the notification message. |
|
Set the auto-dismiss timeout. |
|
Show the notification with slide-in animation from the right. |
eventFilter
¶
Handle parent resize events to reposition notifications.
set_message
¶
Set the notification message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
The new message text. |
required |
set_timeout
¶
Set the auto-dismiss timeout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
Timeout in milliseconds (0 = no auto-dismiss). |
required |
show
¶
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.