shyft.dashboard.base.gate_model
This module contains the gate models.
Gates are used to control the signal flow of Sender to its Receiver.
This is very useful whenever we want to only send data to a widget whenever the user does a specific action, e.g.:
opens a tab
clicks on a button
triggers a selection
If change/different input, then the selectors for the gates, the GatePresenter ties the GateModel and the GateView together:
GatePresenter(GateView, GateModel)
See also ref::gate_presenter.
The information flow is: GateView -> GatePresenter -> GateModel
Whenever the user triggers a GateView, a signal (open/close) is send to the GatePresenter. The GatePresenter triggers the GateModel. The Gate model connects/disconnects its ports.
Classes
|
|
|
Base class and interface for Gates |
|
States of a Gate |
|
Exceptions
Gate Error |
- class shyft.dashboard.base.gate_model.GateState(*values)[source]
Bases:
Enum
States of a Gate
- Open = 1
- Closed = 2
- class shyft.dashboard.base.gate_model.GateBase(logger: LoggerBox | None = None)[source]
Bases:
object
Base class and interface for Gates
- class shyft.dashboard.base.gate_model.SingleGate(sender: Sender, receiver: Receiver, connect_function: connect_ports | connect_state_ports | connect_ports_and_state_ports | None = None, buffer: bool = True, clear_buffer_after_send: bool = False, initial_gate_state: GateState = GateState.Closed, logger: LoggerBox | None = None)[source]
Bases:
GateBase
- __init__(sender: Sender, receiver: Receiver, connect_function: connect_ports | connect_state_ports | connect_ports_and_state_ports | None = None, buffer: bool = True, clear_buffer_after_send: bool = False, initial_gate_state: GateState = GateState.Closed, logger: LoggerBox | None = None) None [source]
A single Gate: Connects a single Sender to a single Receiver when the gate is opened, and disconnects if closed
- Parameters:
sender – sender port for the gate
receiver – receiver port for the gate
connect_function – connection function which should be used, when opening the gate
buffer – Buffer object from sender function during closed gate and send it when gate is opened! This should be True if connected to a Button view
clear_buffer_after_send – Delete buffered object after it was send when gate is opened
initial_gate_state – Initial state of the gate
- class shyft.dashboard.base.gate_model.AggregatedGate(gates=typing.List[shyft.dashboard.base.gate_model.SingleGate], initial_gate_state: GateState | None = GateState.Closed, logger: LoggerBox | None = None)[source]
Bases:
GateBase
- __init__(gates=typing.List[shyft.dashboard.base.gate_model.SingleGate], initial_gate_state: GateState | None = GateState.Closed, logger: LoggerBox | None = None) None [source]
Aggregation of gates, used to control multiple gates derived from GateBase as one gate. This can be used when a GateView e.g. a Button should trigger multiple gates at the same time.
- Parameters:
gates – List of Gates