RQChoice¶
- class pyreaqtive.models.rqchoice.RQChoice(choices, selected=None, allow_none=False)¶
Bases:
pyreaqtive.models.rqmodel.RQModelReactive Choice Model
Represents a choice from a list of choices
- Parameters
choices (pyreaqtive.models.rqlist.RQList) –
selected (pyreaqtive.models.rqmodel.RQModel) –
- __init__(choices, selected=None, allow_none=False)¶
Constructor
- Parameters
choices (pyreaqtive.models.rqlist.RQList) – Initial list of choices
selected (Optional[pyreaqtive.models.rqmodel.RQModel]) – 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
- validate_selected(auto_reset=False)¶
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
- Return type
None
- set(value)¶
Set selected option
- Parameters
value (Optional[pyreaqtive.models.rqmodel.RQModel]) – 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 of RQModels
- Return type
Iterator[pyreaqtive.models.rqmodel.RQModel]