shyft.dashboard.base.selector_presenter
Classes
|
|
|
The TextInputPresenter connects a Model with a TextInput View. |
Exceptions
- exception shyft.dashboard.base.selector_presenter.SelectorPresenterError[source]
Bases:
RuntimeError
- class shyft.dashboard.base.selector_presenter.SelectorPresenter(name: str, view: SelectorViewBase, default: str | Tuple[str, str] = '', logger=None)[source]
Bases:
object
- __init__(name: str, view: SelectorViewBase, default: str | Tuple[str, str] = '', logger=None) None [source]
The presenter is used as connection between Model and View. The presenter is meant to be composed with a Model class as its attribute. Whereas the view is added to the presenter as attribute.
E.i.: model.presenter.view
The Model interacts with the class methods:
set_selector_value
set_selector_options
selector_options
and the port function:
receive_state: to receive an the state of the model ACTIVE or DEACTIVE
The selection is passed back to the view with the send_selection_to_model port. This needs to be connected to a receiver in the model class.
- Parameters:
name – name of the presenter - used in debug msg
view – the view-instance the presenter should connect to
default – default selection primarily used to be able to deselect the selector view, defaults to ‘’ if you do not want an empty select option set default=None
logger – logger instance
- set_selector_value(value: str | List[str], callback: bool = False) None [source]
Method to set the value of the view if options are defined with (key, label), value here should be the key of the option
- Parameters:
value – value the presenter should set the view
callback – if True, the callback is triggered and the selected value is turned back via the send_selection_to_model Port
- set_selector_options(options: List[str | Tuple[str, str]] | None = None, sort: bool = True, selected_value: str | List[str] | None = None, sort_reverse: bool = False, callback: bool = True) None [source]
Method to set the selector options
Options is either List[str] or a List[Tuple[str, str]]. The Tuple[str, str] is equivalent to (key, label) where the label is shown in the selector, but the key is return to the model.
- Parameters:
options – options for the selector
sort – if True sort the selector options alphabetically
selected_value – value to set the selector, needs to be in the options
sort_reverse – if True sort the selector options in reverse order
callback – if True the selected value or default is set with triggering the callback
- property selector_options: List[str | Tuple[str, str]]
- class shyft.dashboard.base.selector_presenter.TextInputPresenter(name: str, view, logger=None)[source]
Bases:
object
The TextInputPresenter connects a Model with a TextInput View. The presenter receives a string from the View, which then will be passed to the Model with the send_text_input_to_model port.