shyft.dashboard.base.selector_presenter¶
Classes
|
The presenter is used as connection between Model and View. |
|
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, view, default='', logger=None)[source]¶
Bases:
objectThe 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 (str) – name of the presenter - used in debug msg
view (SelectorViewBase) – the view-instance the presenter should connect to
default (str | Tuple[str, str]) – 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
- __init__(name, view, default='', logger=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 (str) – name of the presenter - used in debug msg
view (SelectorViewBase) – the view-instance the presenter should connect to
default (str | Tuple[str, str]) – 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
- Return type:
None
- set_selector_value(value, callback=False)[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 (str | List[str]) – value the presenter should set the view
callback (bool) – if True, the callback is triggered and the selected value is turned back via the send_selection_to_model Port
- Return type:
None
- set_selector_options(options=None, sort=True, selected_value=None, sort_reverse=False, callback=True)[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 (List[str | Tuple[str, str]] | None) – options for the selector
sort (bool) – if True sort the selector options alphabetically
selected_value (str | List[str] | None) – value to set the selector, needs to be in the options
sort_reverse (bool) – if True sort the selector options in reverse order
callback (bool) – if True the selected value or default is set with triggering the callback
- Return type:
None
- property selector_options: List[str | Tuple[str, str]]¶
- class shyft.dashboard.base.selector_presenter.TextInputPresenter(name, view, logger=None)[source]¶
Bases:
objectThe 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.
- Parameters:
name (str)