wijjit.elements.input.radio.Radio

class wijjit.elements.input.radio.Radio(name, id=None, classes=None, tab_index=None, label='', checked=False, value='', bind=True)[source]

Radio button element for mutually exclusive selections.

A radio button is part of a group (defined by the ‘name’ attribute) where only one radio can be selected at a time. It renders with unicode circle characters when supported, falling back to ASCII.

Parameters:
  • id (str, optional) – Element identifier

  • name (str) – Group name for mutual exclusion (required)

  • label (str, optional) – Label text displayed next to radio button (default: “”)

  • checked (bool, optional) – Initial checked state (default: False)

  • value (str, optional) – Value to associate with this radio button (default: “”)

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

  • tab_index (int | None)

  • bind (bool | str)

Variables:
  • name (str) – Group name

  • label (str) – Label text

  • checked (bool) – Current checked state

  • value (str) – Associated value

  • on_change (callable or None) – Callback (old_value, new_value) when state changes

  • on_action (callable or None) – Callback when Enter is pressed

  • action (str or None) – Action ID to dispatch (set by template extension)

  • bind (bool) – Whether to auto-bind to state[id] (default: True)

Notes

Radio buttons with the same ‘name’ form a group where only one can be selected at a time. The app manages this mutual exclusion.

Keyboard controls: - Space: Select this radio - Enter: Trigger action - Arrow keys: Navigate within radio group (handled by app)

Mouse controls: - Click: Select this radio

__init__(name, id=None, classes=None, tab_index=None, label='', checked=False, value='', bind=True)[source]
Parameters:
Return type:

None

Methods

__init__(name[, id, classes, tab_index, ...])

add_class(class_name)

Add a CSS class to this element.

apply_props(props)

Apply props from a VNode, skipping ephemeral props.

deselect()

Deselect this radio button (called by group management).

get_ephemeral_state()

Get ephemeral state that should survive reconciliation.

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 keyboard input.

handle_mouse(event)

Handle mouse input.

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_class(class_name)

Remove a CSS class from this element.

render_signature()

Paint memo for the skip-unchanged fast path.

render_to(ctx)

Render radio button using cell-based rendering.

restore_ephemeral_state(state)

Restore ephemeral state after reconciliation.

select()

Select this radio button, deselecting same-group siblings.

set_bounds(bounds)

Set the element's screen bounds.

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.

checked

Get the checked state.

parent_frame

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

supports_dynamic_sizing

Whether this element supports dynamic sizing.

property checked: bool

Get the checked state.

Returns:

Current checked state

Return type:

bool

select()[source]

Select this radio button, deselecting same-group siblings.

Selecting a radio deselects every other radio in radio_group that shares this radio’s name (mutual exclusion). For radios bound to state this is reinforced by the state round-trip, but performing it here means unbound radios behave correctly too. The checked setter fires this radio’s on_change; each deselected sibling fires its own.

Return type:

None

deselect()[source]

Deselect this radio button (called by group management).

Return type:

None

handle_key(key)[source]

Handle keyboard input.

Parameters:

key (Key) – Key press to handle

Returns:

True if key was handled

Return type:

bool

async handle_mouse(event)[source]

Handle mouse input.

Parameters:

event (MouseEvent) – Mouse event to handle

Returns:

True if event was handled

Return type:

bool

render_signature()[source]

Paint memo for the skip-unchanged fast path.

The radio glyph and style follow from checked/focused (folded into _style_signature()); only the label is otherwise read. See wijjit.elements.base.Element.render_signature().

Return type:

Any

render_to(ctx)[source]

Render radio button using cell-based rendering.

Parameters:

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

Return type:

None

Notes

This is the new cell-based rendering method. The legacy render() method is kept for backward compatibility.

Theme styles:

This element uses the following theme style classes: - radio: Base style - radio:focus: When element has focus - radio:selected: When radio is selected