tslumd.tallyobj
- class tslumd.tallyobj.Tally(*args, **kwargs)[source]
Bases:
DispatcherA 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
brightnessvalue normalized as a float from0.0to1.0
- Events:
Added in version 0.0.2: The
on_controleventChanged in version 0.0.5: Added container emulation
- class UpdateKwargs[source]
Bases:
InitKwargsKeyword arguments for use in the
Tally.update()method
- property id: Tuple[int, int]
A key to uniquely identify a
Tally/Screencombination.Tuple of (
Screen.index,Tally.index)- Raises:
ValueError – If the
Tally.screenisNone
Added in version 0.0.3.
- property is_broadcast: bool
Trueif the tally is to be “broadcast”, meaning sent to alldisplay indices.(if the
indexis0xffff)Added in version 0.0.2.
- classmethod broadcast(**kwargs) Tally[source]
Create a
broadcasttally(with
indexset to0xffff)Added in version 0.0.2.
- classmethod from_display(display: Display, screen: Screen | None = None) Tally[source]
Create an instance from the given
Displayobject
- 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_tallyorlh_tallyproperties matching theTallyTypevalue(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
TallyTypemember(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
TallyColorto 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>
Added 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) –
TallyTypemember(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>
Added 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
TallyTypemember(s) to merge. Multiple types can be specified using bitwise|operators.color (TallyColor) – The
TallyColorto merge
Added in version 0.0.4.
- merge(other: Tally, tally_type: TallyType = <TallyType.all_tally: 7>)[source]
Merge the color(s) from another Tally instance into this one using the
merge_color()method- Parameters:
Added in version 0.0.4.
- update(**kwargs: Unpack[UpdateKwargs]) set[str][source]
Update any known properties from the given keyword-arguments
- Returns:
The property names, if any, that changed
- Return type:
- update_from_display(display: Display) set[str][source]
Update this instance from the values of the given
Displayobject- Returns:
The property names, if any, that changed
- Return type:
- to_dict() SerializeTD[source]
Serialize to a
SerializeTD
- to_common_dict() DisplayTallyCommonDict[source]
Return a dict of the common fields between
TallyandDisplayobjectsAdded in version 0.0.8.
- class tslumd.tallyobj.Screen(*args, **kwargs)[source]
Bases:
DispatcherA group of
Tallydisplays- Properties:
- Events:
-
- on_tally_update(tally: Tally, props_changed: set[str])
Fired when any
Tallyproperty changes. This is a retransmission ofTally.on_update
- on_tally_control(tally: Tally, data: bytes)
Fired when control data is received for a
Tallyobject. This is a retransmission ofTally.on_control
Added in version 0.0.3.
- property is_broadcast: bool
Trueif the screen is to be “broadcast”, meaning sent to allscreen indices.(if the
indexis0xffff)
- broadcast_tally(**kwargs: Unpack[InitKwargs]) Tally[source]
Create a temporary
TallyusingTally.broadcast()- Parameters:
**kwargs – Keyword arguments to pass to the
Tallyconstructor
Note
The tally object is not stored in
talliesand no event propagation (on_tally_added,on_tally_update,on_tally_control) is handled by theScreen.
- get_or_create_tally(index_: int) Tally[source]
If a
Tallyobject matching the given index exists, return it. Otherwise create one and add it totalliesThis 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.