tslumd.tallyobj
- class tslumd.tallyobj.Tally(*args, **kwargs)[source]
Bases:
Dispatcher
A single tally object
- Properties:
- rh_tally: TallyColor Property(TallyColor)
State of the right-hand tally indicator
- txt_tally: TallyColor Property(TallyColor)
State of the text tally indicator
- lh_tally: TallyColor Property(TallyColor)
State of the left-hand tally indicator
- normalized_brightness: float Property(float)
The
brightness
value normalized as a float from0.0
to1.0
- Events:
New in version 0.0.2: The
on_control
eventChanged in version 0.0.5: Added container emulation
- classmethod broadcast(**kwargs) Tally [source]
Create a
broadcast
tally(with
index
set to0xffff
)New in version 0.0.2.
- classmethod from_display(display: Display, **kwargs) Tally [source]
Create an instance from the given
Display
object
- set_color(tally_type: str | TallyType, color: str | TallyColor)[source]
Set the color property (or properties) for the given TallyType
Sets the
rh_tally
,txt_tally
orlh_tally
properties matching theTallyType
value(s).If the given tally_type is a combination of tally types, all of the matched attributes will be set to the given color.
- Parameters:
tally_type (TallyType or str) –
The
TallyType
member(s) to set. Multiple types can be specified using bitwise|
operators.If the argument is a string, it should be formatted as shown in
TallyType.from_str()
color (TallyColor or str) – The
TallyColor
to set, or the name as a string
>>> from tslumd import Tally, TallyType, TallyColor >>> tally = Tally(0) >>> tally.set_color(TallyType.rh_tally, TallyColor.RED) >>> tally.rh_tally <TallyColor.RED: 1> >>> tally.set_color('lh_tally', 'green') >>> tally.lh_tally <TallyColor.GREEN: 2> >>> tally.set_color('rh_tally|txt_tally', 'green') >>> tally.rh_tally <TallyColor.GREEN: 2> >>> tally.txt_tally <TallyColor.GREEN: 2> >>> tally.set_color('all', 'off') >>> tally.rh_tally <TallyColor.OFF: 0> >>> tally.txt_tally <TallyColor.OFF: 0> >>> tally.lh_tally <TallyColor.OFF: 0>
New in version 0.0.4.
Changed in version 0.0.5: Allow string arguments and multiple tally_type members
- get_color(tally_type: str | TallyType) TallyColor [source]
Get the color of the given tally_type
If tally_type is a combination of tally types, the color returned will be a combination all of the matched color properties.
- Parameters:
tally_type (TallyType or str) –
TallyType
member(s) to get the color values from.If the argument is a string, it should be formatted as shown in
TallyType.from_str()
>>> tally = Tally(0) >>> tally.get_color('rh_tally') <TallyColor.OFF: 0> >>> tally.set_color('rh_tally', 'red') >>> tally.get_color('rh_tally') <TallyColor.RED: 1> >>> tally.set_color('txt_tally', 'red') >>> tally.get_color('rh_tally|txt_tally') <TallyColor.RED: 1> >>> tally.get_color('all') <TallyColor.RED: 1> >>> tally.set_color('lh_tally', 'green') >>> tally.get_color('lh_tally') <TallyColor.GREEN: 2> >>> tally.get_color('all') <TallyColor.AMBER: 3>
New in version 0.0.5.
- merge_color(tally_type: TallyType, color: TallyColor)[source]
Merge the color property (or properties) for the given TallyType using the
set_color()
methodCombines the existing color value with the one provided using a bitwise
|
(or) operation- Parameters:
tally_type (TallyType) – The
TallyType
member(s) to merge. Multiple types can be specified using bitwise|
operators.color (TallyColor) – The
TallyColor
to merge
New in version 0.0.4.
- merge(other: Tally, tally_type: TallyType = TallyType.all_tally)[source]
Merge the color(s) from another Tally instance into this one using the
merge_color()
method- Parameters:
New in version 0.0.4.
- update(**kwargs) set[str] [source]
Update any known properties from the given keyword-arguments
- Returns:
The property names, if any, that changed
- Return type:
- class tslumd.tallyobj.Screen(*args, **kwargs)[source]
Bases:
Dispatcher
A group of
Tally
displays- Properties:
- Events:
-
- on_tally_update(tally: Tally, props_changed: set[str])
Fired when any
Tally
property changes. This is a retransmission ofTally.on_update
- on_tally_control(tally: Tally, data: bytes)
Fired when control data is received for a
Tally
object. This is a retransmission ofTally.on_control
New in version 0.0.3.
- classmethod broadcast(**kwargs) Screen [source]
Create a
broadcast
Screen
(with
index
set to0xffff
)
- broadcast_tally(**kwargs) Tally [source]
Create a temporary
Tally
usingTally.broadcast()
- Parameters:
**kwargs – Keyword arguments to pass to the
Tally
constructor
Note
The tally object is not stored in
tallies
and no event propagation (on_tally_added
,on_tally_update
,on_tally_control
) is handled by theScreen
.
- add_tally(index_: int, **kwargs) Tally [source]
Create a
Tally
object and add it totallies
- Parameters:
index – The tally
index
**kwargs – Keyword arguments passed to create the tally instance
- Raises:
KeyError – If the given
index_
already exists
- get_or_create_tally(index_: int) Tally [source]
If a
Tally
object matching the given index exists, return it. Otherwise create one and add it totallies
This method is similar to
add_tally()
and it can be used to avoid exception handling. It does not however take keyword arguments and is only intended for object creation.