wijjit.elements.display.notification.NotificationElement
- class wijjit.elements.display.notification.NotificationElement(message, id=None, classes=None, severity=NotificationSeverity.INFO, action_label=None, action_callback=None, dismiss_on_action=True, max_width=60)[source]
Notification element for temporary messages.
This element renders as a compact notification box with icon, message, and optional action button. Notifications are typically displayed in a corner of the screen and can auto-dismiss after a timeout.
- Parameters:
message (
str) – Notification message textid (
str, optional) – Unique identifierseverity (
strorNotificationSeverity, optional) – Severity level: “success”, “error”, “warning”, or “info” (default: “info”)action_label (
str, optional) – Label for action button (if None, no button shown)action_callback (
callable, optional) – Callback when action button is clickeddismiss_on_action (
bool, optional) – Whether to auto-dismiss when action is clicked (default: True)max_width (
int, optional) – Maximum notification width (default: 60)
- Variables:
message (
str) – Notification messageseverity (
NotificationSeverity) – Severity levelaction_callback (
callableorNone) – Action button callbackdismiss_on_action (
bool) – Auto-dismiss on action flagmax_width (
int) – Maximum widthframe (
Frame) – Frame rendereraction_button (
ButtonorNone) – Action button element (if action_label provided)on_dismiss (
callableorNone) – Callback when notification is dismissed
- __init__(message, id=None, classes=None, severity=NotificationSeverity.INFO, action_label=None, action_callback=None, dismiss_on_action=True, max_width=60)[source]
Methods
__init__(message[, id, classes, severity, ...])add_child(element)Add a child element.
add_class(class_name)Add a CSS class to this element.
apply_props(props)Apply props from a VNode, skipping ephemeral props.
get_ephemeral_state()Get ephemeral state that should survive reconciliation.
get_focusable_children()Get all focusable child elements.
get_hardware_cursor_position()Absolute screen cell where the hardware terminal cursor should park.
get_height_for_width(width)Return the height this element needs when laid out at
width.get_intrinsic_size()Get the intrinsic (preferred) size of the element.
handle_key(key)Handle key press by routing to focused child.
handle_mouse(event)Handle mouse events on notification.
has_class(class_name)Check if element has a CSS class.
on_blur()Called when element loses focus.
on_focus()Called when element gains focus.
on_hover_enter()Called when mouse enters element.
on_hover_exit()Called when mouse exits element.
on_mount()Called when element is first added to the element tree.
on_unmount()Called when element is removed from the element tree.
on_update(changed_props)Called when element props are updated during reconciliation.
remove_child(element)Remove a child element.
remove_class(class_name)Remove a CSS class from this element.
render_signature()Hashable/comparable capture of everything
render_to()reads.render_to(ctx)Render the notification using cell-based rendering (NEW API).
restore_ephemeral_state(state)Restore ephemeral state after reconciliation.
set_bounds(bounds)Set the element's screen bounds.
toggle_class(class_name)Toggle a CSS class on this element.
Attributes
captures_tabWhether this element wants the Tab key instead of focus movement.
parent_frameGet the parent Frame if this element is inside a scrollable frame.
supports_dynamic_sizingWhether this element supports dynamic sizing.
- render_to(ctx)[source]
Render the notification using cell-based rendering (NEW API).
- Parameters:
ctx (
PaintContext) – Paint context with buffer, style resolver, and bounds- Return type:
None
Notes
This method uses cell-based rendering with theme styles for severity-based coloring. It delegates to Frame’s render_to() method for the container and handles icon/message/button layout.
Theme styles:
This element uses the following theme style classes: -
notification.info: Info notification style -notification.success: Success notification style -notification.warning: Warning notification style -notification.error: Error notification style -frame.border: Border style (inherited from Frame)