@@ -23,8 +23,7 @@ def __init__(self):
2323 self .initialize_variables ()
2424 self .create_gui ()
2525 self ._file_setup ()
26- self .create_time_spent_graph ()
27- self .create_weekday_graph ()
26+
2827 self .WINDOW .protocol ("WM_DELETE_WINDOW" , self .save_on_quit )
2928
3029
@@ -324,13 +323,17 @@ def _format_func(value, tick_number):
324323 time_spent_graph .grid (row = 0 , column = 0 , padx = 10 , pady = 10 )
325324 time_spent_graph .config (highlightbackground = frame_border_color , highlightthickness = 2 , background = frame_color )
326325
327- self .data_manager .clear_graph_lists ()
328-
329326
330327 def create_weekday_graph (self ):
331- day_duration_list = self .data_manager .collect_day_data ()
332- non_zero_durations = [duration for duration in day_duration_list if duration != 0 ]
333- non_zero_names = [name for name , duration in zip (self .data_manager .day_name_list , day_duration_list ) if duration != 0 ]
328+ self .data_manager .collect_day_data ()
329+
330+ if self .data_manager .day_duration_list :
331+ non_zero_durations = [duration for duration in self .data_manager .day_duration_list if duration != 0 ]
332+ non_zero_names = [name for name , duration in zip (self .data_manager .day_name_list , self .data_manager .day_duration_list ) if duration != 0 ]
333+
334+ else :
335+ non_zero_durations = [0 ]
336+ non_zero_names = []
334337
335338 def _autopct_format (values ):
336339 def _my_format (pct ):
@@ -340,9 +343,8 @@ def _my_format(pct):
340343 return _my_format
341344
342345 fig , ax = plt .subplots ()
343- ax .pie (non_zero_durations , labels = non_zero_names , autopct = _autopct_format (non_zero_durations ),
344- colors = self .data_manager .pie_colors ,
345- textprops = {"fontsize" : pie_font_size , "family" : pie_font_family , "color" : font_color }, counterclock = False , startangle = 90 )
346+ ax .pie (non_zero_durations , labels = non_zero_names , autopct = _autopct_format (non_zero_durations ), colors = self .data_manager .pie_colors ,
347+ textprops = {"fontsize" : pie_font_size , "family" : pie_font_family , "color" : font_color }, counterclock = False , startangle = 90 )
346348 fig .set_size_inches (graph_width / 100 , graph_height / 100 , forward = True )
347349 fig .set_facecolor (graph_bg_color )
348350 ax .tick_params (colors = "white" )
@@ -359,6 +361,11 @@ def _my_format(pct):
359361 weekday_graph .grid (row = 0 , column = 1 , padx = 10 , pady = 10 )
360362 weekday_graph .config (highlightbackground = frame_border_color , highlightthickness = 2 , background = frame_color )
361363
364+
365+ def create_graphs (self ):
366+ self .create_time_spent_graph ()
367+ self .create_weekday_graph ()
368+
362369
363370 def forget_and_propagate (self , list : list ):
364371 for item in list :
@@ -399,6 +406,7 @@ def reset_gui_values(self):
399406 self .times_goal_reached .configure (text = 0 )
400407 self .streak_duration .configure (text = 0 )
401408 self .progressbar .set (0 )
409+ self .progressbar .configure (progress_color = self .data_manager .color )
402410 self .reset_timers ()
403411
404412
0 commit comments