@@ -106,13 +106,23 @@ def handle_event(self, event: Message) -> None:
106106 lesson .delay ,
107107 next_lesson .prepare - lesson .finish
108108 )
109+ self .main_window .class_advance_label ['text' ] = "下课"
109110 elif event [0 ] == MessageEnum .ClassAdvance :
110- self .set_windows_topmost (False )
111- self .state .lesson_state = LessonState .AtClass
112- if self .state .current_lesson > 0 :
113- self .main_window .class_labels [
114- self .state .current_lesson - 1 ]['fg' ] = self .state .color_theme .fg
115- self .main_window .class_labels [self .state .current_lesson ]['fg' ] = self .state .color_theme .hint
111+ if event [1 ] == 'on' :
112+ self .set_windows_topmost (False )
113+ self .state .lesson_state = LessonState .AtClass
114+ if self .state .current_lesson > 0 :
115+ self .main_window .class_labels [
116+ self .state .current_lesson - 1 ]['fg' ] = self .state .color_theme .fg
117+ self .main_window .class_labels [self .state .current_lesson ]['fg' ] = self .state .color_theme .hint
118+ self .main_window .class_advance_label ['text' ] = "下课"
119+ else :
120+ self .state .current_lesson += 1
121+ if self .state .current_lesson < len (self .state .lessons ):
122+ self .state .lesson_state = LessonState .Break
123+ else :
124+ self .state .lesson_state = LessonState .AfterSchool
125+ self .main_window .class_advance_label ['text' ] = "上课"
116126
117127 else :
118128 assert False , event # unreachable
@@ -126,8 +136,10 @@ def handle_poll(self, event: PollResult, update: bool) -> bool:
126136 return True
127137 elif event [0 ] == PollEnum .ClassBegin :
128138 self .set_windows_topmost (False )
139+ self .main_window .class_advance_label ['text' ] = "下课"
129140 elif event [0 ] == PollEnum .ClassFinish :
130141 self .set_windows_topmost (True )
142+ self .main_window .class_advance_label ['text' ] = "上课"
131143 elif event [0 ] == PollEnum .ClassPrepare :
132144 if update :
133145 self .main_window .bell ()
@@ -171,11 +183,12 @@ def poll_update(self):
171183 self .format_minutes (last , min (MIN_POINT , total / 2 )), total
172184 )
173185 current_lesson = self .state .current_lesson
186+ pass_ratio = max (min (last / total , 1 ), 0 )
174187 if current_lesson > 0 :
175188 self .main_window .class_labels [current_lesson ]['fg' ] = self .state .color_theme .gradient (
176- last / total / 2 )
189+ pass_ratio / 2 )
177190 self .main_window .class_labels [
178- current_lesson - 1 ]['fg' ] = self .state .color_theme .gradient (1 - last / total / 2 )
191+ current_lesson - 1 ]['fg' ] = self .state .color_theme .gradient (1 - pass_ratio / 2 )
179192 elif self .state .lesson_state == LessonState .BeforeSchool :
180193 first_lesson = self .state .i_lesson (0 )
181194 text = "{}" .format (self .format_minutes (self .minute (
0 commit comments