Skip to content

Radioset

RadioSet

Bases: Container

Widget for grouping a collection of radio buttons into a set.

When a collection of RadioButtons are grouped with this widget, they will be treated as a mutually-exclusive grouping. If one button is turned on, the previously-on button will be turned off.

pressed_button: RadioButton | None property

The currently-pressed button, or None if none are pressed.

pressed_index: int property

The index of the currently-pressed button, or -1 if none are pressed.

Changed

Bases: Message

Posted when the pressed button in the set changes.

This message can be handled using an on_radio_set_changed method.

index instance-attribute

The index of the RadioButton that was pressed to make the change.

pressed instance-attribute

The RadioButton that was pressed to make the change.

radio_set instance-attribute

A reference to the RadioSet that was changed.

__init__(radio_set, pressed)

Initialise the message.

Parameters:

Name Type Description Default
pressed RadioButton

The radio button that was pressed.

required

__init__(*buttons, name=None, id=None, classes=None, disabled=False)

Initialise the radio set.

Parameters:

Name Type Description Default
buttons str | RadioButton

A collection of labels or RadioButtons to group together.

()
name str | None

The name of the radio set.

None
id str | None

The ID of the radio set in the DOM.

None
classes str | None

The CSS classes of the radio set.

None
disabled bool

Whether the radio set is disabled or not.

False
Note

When a str label is provided, a RadioButton will be created from it.

on_mount()

Perform some processing once mounted in the DOM.

on_radio_button_changed(event)

Respond to the value of a button in the set being changed.

Parameters:

Name Type Description Default
event RadioButton.Changed

The event.

required