@@ -49,18 +49,16 @@ def update_tallies(self, tallies: Iterable[Tally]) -> List[int]:
49
49
50
50
class AnimatedSender (UmdSender ):
51
51
tally_groups : Dict [TallyType , TallyTypeGroup ]
52
- def __init__ (self , clients = None , num_tallies = 8 , update_interval = .5 , screen = 1 ):
52
+ def __init__ (self , clients = None , num_tallies = 8 , update_interval = .5 , screen = 1 , all_off_on_close = False ):
53
53
self .num_tallies = num_tallies
54
54
self .update_interval = update_interval
55
- super ().__init__ (clients )
55
+ super ().__init__ (clients , all_off_on_close )
56
56
self .screen = self .get_or_create_screen (screen )
57
57
for i in range (self .num_tallies ):
58
58
self .screen .add_tally (i , text = string .ascii_uppercase [i ])
59
59
60
60
self .tally_groups = {}
61
- for tally_type in TallyType :
62
- if tally_type == TallyType .no_tally :
63
- continue
61
+ for tally_type in TallyType .all ():
64
62
tg = TallyTypeGroup (tally_type , self .num_tallies )
65
63
self .tally_groups [tally_type ] = tg
66
64
@@ -124,7 +122,7 @@ def animate_vertical(self):
124
122
self .cur_index = start_ix
125
123
126
124
def animate_horizontal (self ):
127
- tally_types = [t for t in TallyType ]
125
+ tally_types = [t for t in TallyType if t != TallyType . all_tally ]
128
126
while tally_types [0 ] != self .cur_group :
129
127
t = tally_types .pop (0 )
130
128
tally_types .append (t )
@@ -139,7 +137,13 @@ def animate_horizontal(self):
139
137
color = TallyColor .OFF
140
138
tg .tally_colors [self .cur_index ] = color
141
139
try :
142
- t = TallyType (self .cur_group .value + 1 )
140
+ if self .cur_group .value == 0 :
141
+ v = 1
142
+ else :
143
+ v = self .cur_group .value * 2
144
+ if v > TallyType .all_tally .value :
145
+ raise ValueError ()
146
+ t = TallyType (v )
143
147
self .cur_group = t
144
148
except ValueError :
145
149
self .cur_index += 1
@@ -154,7 +158,7 @@ async def update_loop(self):
154
158
def update_tallies ():
155
159
changed = set ()
156
160
for tg in self .tally_groups .values ():
157
- _changed = tg .update_tallies (self .tallies .values ())
161
+ _changed = tg .update_tallies (self .screen . tallies .values ())
158
162
changed |= set (_changed )
159
163
return changed
160
164
@@ -178,6 +182,9 @@ def main():
178
182
p .add_argument (
179
183
'-n' , '--num-tallies' , dest = 'num_tallies' , type = int , default = 8 ,
180
184
)
185
+ p .add_argument (
186
+ '-a' , '--all-of-on-close' , dest = 'all_off_on_close' , action = 'store_true' ,
187
+ )
181
188
p .add_argument (
182
189
'-i' , '--interval' , dest = 'update_interval' , type = float , default = .5 ,
183
190
)
0 commit comments