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, ...])

GateBase([logger])

Base class and interface for Gates

GateState(value[, names, module, qualname, ...])

States of a Gate

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

Exceptions

GateError

Gate Error

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

Bases: RuntimeError

Gate Error

class shyft.dashboard.base.gate_model.GateState(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[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

__init__(logger: LoggerBox | None = None)[source]

Base function for gates

abstract open() None[source]

Function to open the gate

abstract close()[source]

Function to close the gate

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

open() None[source]

Function to open the gate

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 | 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

open() None[source]

Function to open the gate

close()[source]

Function to close the gate