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 |
|---|---|---|---|
|
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 a single action button. Sugar for a one-entry
|
None
|
|
Optional[Mapping[str, Callable[[], None]]]
|
Buttons to put on the banner, as |
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_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 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:
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.