Skip to content

RadioGroup

pywry.toolbar.RadioGroup

Bases: ToolbarItem

A group of radio buttons for single selection.

Emits {value: ...} on selection change.

ATTRIBUTE DESCRIPTION
options

List of Option objects for the radio group.

TYPE: list of Option

selected

Currently selected value.

TYPE: str

direction

Layout direction - "horizontal" or "vertical".

TYPE: str

Examples:

>>> RadioGroup(
...     label="View:",
...     event="view:change",
...     options=[
...         Option(label="List", value="list"),
...         Option(label="Grid", value="grid"),
...     ],
...     selected="list",
...     direction="horizontal",
... )

Functions

normalize_options classmethod

normalize_options(v: Any) -> list[Option]

Accept list of dicts or Option objects.

build_html

build_html() -> str

Build radio group HTML.

auto_generate_component_id

auto_generate_component_id() -> ToolbarItem

Auto-generate component_id based on type if not provided.

validate_event_name classmethod

validate_event_name(v: str) -> str

Validate event follows namespace:event-name pattern.