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,
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 |
|---|---|---|---|
|
Optional[QWidget]
|
Parent widget (required for positioning). |
None
|
|
str
|
The notification message. |
''
|
|
Optional[int]
|
Severity level (CRITICAL, ERROR, WARNING, SUCCESS, INFO, DEBUG). If None, a custom notification is shown using title and icon. |
None
|
|
int
|
Auto-dismiss timeout in milliseconds (0 = no auto-dismiss). |
5000
|
|
Optional[str]
|
Text for the optional action button. |
None
|
|
bool
|
Whether to show a close button. |
True
|
|
int
|
Fixed width of the notification card (default 320). |
320
|
|
Optional[Logger]
|
A logger object to log the message when shown. The severity level is mapped to the appropriate logging level. |
None
|
|
Optional[str]
|
Custom title for the notification. Overrides severity-based title. |
None
|
|
Optional[str]
|
Custom icon name for the notification. Overrides severity-based icon. |
None
|
|
int
|
Margin from the edges of the parent widget (default 16). |
16
|
|
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. |
Functions¶
eventFilter
¶
eventFilter(obj, event) -> bool
Handle parent resize events to reposition notifications.
set_message
¶
set_timeout
¶
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.