RQChoice

class pyreaqtive.models.rqchoice.RQChoice(choices, selected=None, allow_none=False)

Bases: pyreaqtive.models.rqmodel.RQModel

Reactive Choice Model

Represents a choice from a list of choices

Parameters
__init__(choices, selected=None, allow_none=False)

Constructor

Parameters
rq_choices_list

Reactive list of available choices

selected: Optional[Any]

Selected item

Can be None if allow_none is True

_allow_none: bool

Indicates if model accepts choice none apart from the list of choices

get()

Get current selection

Returns

Selected Model

Return type

Any

get_choices()

Get list of choices

Returns

List of choices

Return type

Union[pyreaqtive.models.rqlist.RQList, List]

validate_selected(auto_reset=False)

Validate that the current selection is none or is a valid choice from the choices list

Parameters

auto_reset (bool) – if True, when selected is not valid resets the selection if False, raises KeyError Exception

Return type

None

set(value)

Set selected option

Parameters

value (Optional[Any]) – New selected choice

Return type

None

reset()

Reset selection to default value

If allow_none is True default is None, else is the first element

Return type

None

__str__()

Get current choice in string format

Returns

value in string of the current choice model

Return type

str

__iter__()

Iterator of the choices of the list

Returns

Iterator

Return type

Iterator[Any]

__getitem__(index)

Get item of the choices of the list

Parameters

index (int) – element of the list

Returns

item in the list indicated by index

Return type

Any