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 identifiername (
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: “”)tab_index (int | None)
- Variables:
name (
str) – Group namelabel (
str) – Label textchecked (
bool) – Current checked statevalue (
str) – Associated valueon_change (
callableorNone) – Callback (old_value, new_value) when state changeson_action (
callableorNone) – Callback when Enter is pressedaction (
strorNone) – 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]
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.
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_tabWhether this element wants the Tab key instead of focus movement.
Get the checked state.
parent_frameGet the parent Frame if this element is inside a scrollable frame.
supports_dynamic_sizingWhether this element supports dynamic sizing.
- select()[source]
Select this radio button, deselecting same-group siblings.
Selecting a radio deselects every other radio in
radio_groupthat shares this radio’sname(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. Thecheckedsetter fires this radio’son_change; each deselected sibling fires its own.- 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:
- async handle_mouse(event)[source]
Handle mouse input.
- Parameters:
event (
MouseEvent) – Mouse event to handle- Returns:
True if event was handled
- Return type:
- 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. Seewijjit.elements.base.Element.render_signature().- Return type:
- 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