Skip to content

TabGroup

pywry.toolbar.TabGroup

Bases: ToolbarItem

A group of tabs for single-value selection with tab-style appearance.

Similar to RadioGroup but styled as tabs. Useful for view switching, mode selection, or any mutually exclusive option set that benefits from a tab-like visual appearance.

Emits {componentId: ..., value: ...} on tab change.

ATTRIBUTE DESCRIPTION
options

List of Option objects (label + value).

TYPE: list of Option

selected

Currently selected value.

TYPE: str

size

Tab size - "sm", "md" (default), or "lg".

TYPE: str

Examples:

>>> TabGroup(
...     label="View:",
...     event="view:change",
...     options=[
...         Option(label="Table", value="table"),
...         Option(label="Chart", value="chart"),
...         Option(label="Map", value="map"),
...     ],
...     selected="table",
... )

Functions

normalize_options classmethod

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

Accept list of dicts or Option objects.

build_html

build_html() -> str

Build tab 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.