RQChoice

class pyreaqtive.models.rqchoice.RQChoice(choices: pyreaqtive.models.rqlist.RQList, selected: Optional[pyreaqtive.models.rqmodel.RQModel] = None, allow_none=False)

Bases: pyreaqtive.models.rqmodel.RQModel

Reactive Choice Model

Represents a choice from a list of choices

__init__(choices: pyreaqtive.models.rqlist.RQList, selected: Optional[pyreaqtive.models.rqmodel.RQModel] = None, allow_none=False)

Constructor

Parameters
  • choices – Initial list of choices

  • selected – Initial choice selected

rq_choices_list: pyreaqtive.models.rqlist.RQList

Reactive list of available choices

selected: Optional[pyreaqtive.models.rqmodel.RQModel]

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()pyreaqtive.models.rqmodel.RQModel

Get current selection

Returns

Selected Model

Return type

RQModel

get_choices()pyreaqtive.models.rqlist.RQList

Get list of choices

Returns

List of choices

Return type

RQList

validate_selected(auto_reset=False)None

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

Parameters

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

set(value: Optional[pyreaqtive.models.rqmodel.RQModel])None

Set selected option

Parameters

value – New selected choice

reset()None

Reset selection to default value

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

__str__()str

Get current choice in string format

Returns

value in string of the current choice model

Return type

str

__iter__()Iterator[pyreaqtive.models.rqmodel.RQModel]

Iterator of the choices of the list

Returns

Iterator of RQModels