yr.buttons

buttons(
    options: list[str],
    label: str | None = None,
) → str

Present the user with a set of buttons and return their selection.

Parameters

options
type: list[str]

Labels for the buttons to display.

label
type: str | None = None

Optional prompt shown above the buttons.

Returns

type: str

The label of the button the user clicked.

Raises

InputValueError

If the submitted value is not one of the offered button labels.

Examples

Ask the user to choose from several options:

python
import yera as yr

drink = yr.buttons(
    ["Tea", "Coffee", "Water"],
    label="What would you like to drink?",
)