wijjit.elements.modal.AlertDialog

class wijjit.elements.modal.AlertDialog(message, on_ok=None, title='Alert', classes=None, ok_label='OK', severity=None, width=50, height=None, border_style='single', id=None)[source]

Alert dialog with a message and OK button.

This dialog presents a message with a single OK button and executes the callback when the button is clicked. The dialog automatically closes after the button is clicked.

Parameters:
  • title (str, optional) – Dialog title (default: “Alert”)

  • message (str) – Alert message to display

  • on_ok (callable, optional) – Callback function called when OK button is clicked

  • ok_label (str, optional) – Label for OK button (default: “OK”)

  • severity (str or AlertSeverity, optional) – Alert severity level: “success”, “error”, “warning”, or “info” Affects border color styling (default: None, no color styling)

  • width (int, optional) – Dialog width in characters (default: 50, or auto-sized if None)

  • height (int, optional) – Dialog height in lines (default: auto-sized based on content)

  • border_style (str, optional) – Border style: “single”, “double”, or “rounded” (default: “single”)

  • classes (str | list[str] | set[str] | None)

  • id (str | None)

Variables:
  • message (str) – Dialog message

  • severity (AlertSeverity or None) – Alert severity level

  • ok_button (Button) – OK button element

  • close_callback (callable or None) – Callback to close the dialog (set externally by app)

__init__(message, on_ok=None, title='Alert', classes=None, ok_label='OK', severity=None, width=50, height=None, border_style='single', id=None)[source]
Parameters:
Return type:

None

Methods

__init__(message[, on_ok, title, classes, ...])

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.

calculate_content_bounds()

Calculate the bounds available for content inside the frame.

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 event by routing to child at mouse position.

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 alert dialog with severity-based border styling.

restore_ephemeral_state(state)

Restore ephemeral state after reconciliation.

set_bounds(bounds)

Set the element's screen bounds.

set_content(content)

Set the modal content text.

toggle_class(class_name)

Toggle a CSS class on this element.

Attributes

captures_tab

Whether this element wants the Tab key instead of focus movement.

parent_frame

Get the parent Frame if this element is inside a scrollable frame.

supports_dynamic_sizing

Whether this element supports dynamic sizing.

render_to(ctx)[source]

Render the alert dialog with severity-based border styling.

Parameters:

ctx (PaintContext) – Paint context with buffer, style resolver, and bounds

Return type:

None

Notes

This method uses theme style classes for severity-based coloring: - alert.success.border: Success alert border style (default: green) - alert.error.border: Error alert border style (default: red) - alert.warning.border: Warning alert border style (default: yellow) - alert.info.border: Info alert border style (default: blue)