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

AggregatedGate([gates, initial_gate_state, ...])

Aggregation of gates, used to control multiple gates derived from GateBase as one gate.

GateBase([logger])

Base class and interface for Gates

GateState(*values)

States of a Gate

SingleGate(sender, receiver[, ...])

A single Gate: Connects a single Sender to a single Receiver when the gate is opened, and disconnects if closed

Exceptions

GateError

Gate Error

exception shyft.dashboard.base.gate_model.GateError[source]

Bases: RuntimeError

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=None)[source]

Bases: object

Base class and interface for Gates

Base function for gates

Parameters:

logger (LoggerBox | None)

__init__(logger=None)[source]

Base function for gates

Parameters:

logger (LoggerBox | None)

abstractmethod open()[source]

Function to open the gate

Return type:

None

abstractmethod close()[source]

Function to close the gate

class shyft.dashboard.base.gate_model.SingleGate(sender, receiver, connect_function=None, buffer=True, clear_buffer_after_send=False, initial_gate_state=GateState.Closed, logger=None)[source]

Bases: GateBase

A single Gate: Connects a single Sender to a single Receiver when the gate is opened, and disconnects if closed

Parameters:
  • sender (Sender) – sender port for the gate

  • receiver (Receiver) – receiver port for the gate

  • connect_function (connect_ports | connect_state_ports | connect_ports_and_state_ports | None) – connection function which should be used, when opening the gate

  • buffer (bool) – 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 (bool) – Delete buffered object after it was send when gate is opened

  • initial_gate_state (GateState) – Initial state of the gate

  • logger (LoggerBox | None)

__init__(sender, receiver, connect_function=None, buffer=True, clear_buffer_after_send=False, initial_gate_state=GateState.Closed, logger=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) – sender port for the gate

  • receiver (Receiver) – receiver port for the gate

  • connect_function (connect_ports | connect_state_ports | connect_ports_and_state_ports | None) – connection function which should be used, when opening the gate

  • buffer (bool) – 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 (bool) – Delete buffered object after it was send when gate is opened

  • initial_gate_state (GateState) – Initial state of the gate

  • logger (LoggerBox | None)

Return type:

None

open()[source]

Function to open the gate

Return type:

None

close()[source]

Function to close the gate

class shyft.dashboard.base.gate_model.AggregatedGate(gates=typing.List[shyft.dashboard.base.gate_model.SingleGate], initial_gate_state=GateState.Closed, logger=None)[source]

Bases: GateBase

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:
__init__(gates=typing.List[shyft.dashboard.base.gate_model.SingleGate], initial_gate_state=GateState.Closed, logger=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:
Return type:

None

open()[source]

Function to open the gate

Return type:

None

close()[source]

Function to close the gate