99import customtkinter as ctk
1010from styles import *
1111from matplotlib .ticker import MaxNLocator
12- from win11toast import toast
12+ from winotify import Notification
1313import random
1414from matplotlib .ticker import FuncFormatter
1515
4141color = "Orange"
4242default_color = ctk .StringVar (value = color )
4343notification_limit = False
44+ default_subject = ctk .StringVar (value = "Other" )
45+ current_subject = "Other"
46+ subject = ""
4447
4548
4649main_frame = ctk .CTkFrame (WINDOW , fg_color = main_frame_color , height = HEIGHT + ((widget_padding_x + frame_padding )* 2 ), width = WIDTH , corner_radius = 0 )
@@ -73,7 +76,7 @@ def customize_excel(worksheet):
7376 worksheet ["B1" ].value = "End:"
7477 worksheet ["C1" ].value = "Duration:"
7578 worksheet ["D1" ].value = "Break:"
76- worksheet ["E1" ].value = "Streak :"
79+ worksheet ["E1" ].value = "Subject :"
7780
7881 worksheet ["U1" ].value = "Monday:"
7982 worksheet ["U2" ].value = "Tuesday:"
@@ -252,7 +255,7 @@ def my_format(pct):
252255
253256
254257def collect_data ():
255- global data_amount , date_list , duration_list , goal_amount , total_duration , day_duration_list , day_name_list
258+ global data_amount , date_list , duration_list , goal_amount , total_duration , day_duration_list , day_name_list , current_subject , default_subject
256259 global monday_amount , tuesday_amount , wednesday_amount , thursday_amount , friday_amount , saturday_amount , sunday_amount
257260 global monday_duration , tuesday_duration , wednesday_duration , thursday_duration , friday_duration , saturday_duration , sunday_duration
258261 global color , default_color , pie_color_1 , pie_color_2 , pie_color_3 , pie_color_4 , pie_color_5 , pie_color_6 , pie_color_7
@@ -277,6 +280,11 @@ def collect_data():
277280
278281 goal_amount = int (worksheet ["R1" ].value )
279282
283+ current_subject = worksheet ["Q1" ].value
284+ if current_subject == None or current_subject == "" :
285+ current_subject = "Other"
286+ default_subject = ctk .StringVar (value = current_subject )
287+
280288 color = worksheet ["T1" ].value
281289 if color == None :
282290 color = "Orange"
@@ -375,7 +383,7 @@ def update_break_time():
375383#------------------------------------------------------------------------------DATA-----------------------------------------------------------------------------#
376384def save_data ():
377385 global data_amount , duration_list , date_list , goal_amount , time_studied_label , total_duration , times_studied_label , progressbar , notification_limit
378- global timer_running , timer_time , start_time , timer_btn , timer_label
386+ global timer_running , timer_time , start_time , timer_btn , timer_label , current_subject , subject
379387 global break_running , break_time , break_btn , break_label
380388
381389 if timer_time < 60 :
@@ -386,6 +394,9 @@ def save_data():
386394 notification_limit = False
387395 timer_running , break_running = False , False
388396
397+ if subject == "" or subject == None :
398+ subject = "Other"
399+
389400 duration = calculate_duration ()
390401
391402 data_amount += 1
@@ -397,6 +408,7 @@ def save_data():
397408 worksheet ["B" + str ((data_amount + 1 ))].value = stop_time .strftime ("%d/%m/%Y %H:%M" )
398409 worksheet ["C" + str ((data_amount + 1 ))].value = duration
399410 worksheet ["D" + str ((data_amount + 1 ))].value = break_time / 60
411+ worksheet ["E" + str ((data_amount + 1 ))].value = subject
400412
401413 timer_btn .configure (text = "Start" )
402414 break_btn .configure (text = "Start" )
@@ -406,7 +418,6 @@ def save_data():
406418 workbook .save (data_file )
407419
408420 if timer_time / 60 >= goal :
409- progressbar .set (1 )
410421 goal_amount += 1
411422 worksheet ["R1" ].value = goal_amount
412423 times_studied_label .configure (text = goal_amount )
@@ -454,7 +465,8 @@ def reset_data():
454465
455466def send_notification (title , message ):
456467 global notification_limit
457- toast (title , message )
468+ toast = Notification (app_id = APPNAME , title = title , msg = message )
469+ toast .show ()
458470 notification_limit = True
459471 print ("Notification " + title + " sent." )
460472
@@ -519,6 +531,7 @@ def load_history():
519531 end_history = ""
520532 duration_history = ""
521533 break_history = ""
534+ subject_history = ""
522535 if data_amount > 0 :
523536 for data in range (data_amount + 1 , 1 , - 1 ):
524537 start_history += str (worksheet ["A" + str (data )].value )
@@ -529,15 +542,20 @@ def load_history():
529542 duration_history += "\n "
530543 break_history += str (round (worksheet ["D" + str (data )].value )) + "m"
531544 break_history += "\n "
545+ subject_history += str (worksheet ["E" + str (data )].value )
546+ subject_history += "\n "
547+
532548 start_text .configure (text = start_history )
533549 end_text .configure (text = end_history )
534550 duration_text .configure (text = duration_history )
535551 break_text .configure (text = break_history )
552+ subject_text .configure (text = subject_history )
536553 else :
537554 start_text .configure (text = "-" )
538555 end_text .configure (text = "-" )
539556 duration_text .configure (text = "-" )
540557 break_text .configure (text = "-" )
558+ subject_text .configure (text = "-" )
541559
542560
543561def set_goal ():
@@ -609,6 +627,15 @@ def set_color(widget):
609627 highlight_color = highlight_colors [color ]
610628 graph_color = c
611629 change_color (c , highlight_color , widget_list , progressbar )
630+
631+
632+ def set_subject ():
633+ global current_subject , subject
634+ current_subject = subject_selection .get ()
635+ subject = current_subject
636+ worksheet ["Q1" ].value = current_subject
637+ workbook .save (data_file )
638+ print ("Subject set and saved." )
612639
613640#------------------------------------------------------------------------------GUI------------------------------------------------------------------------------#
614641#clock_image = ctk.CTkImage(light_image=Image.open("images/clock.png"), size=(image_width, image_height))
@@ -668,7 +695,7 @@ def change_focus(event):
668695
669696timer_break_frame = ctk .CTkFrame (main_frame , height = (HEIGHT - button_height * 1.5 ), width = frame_width )
670697timer_break_frame .grid (row = 0 , column = 1 )
671- timer_break_frame .propagate (False )
698+ timer_break_frame .pack_propagate (False )
672699
673700timer_frame = ctk .CTkFrame (timer_break_frame , fg_color = frame_color , corner_radius = 10 , width = frame_width , height = 220 )
674701timer_frame .pack (padx = frame_padding , pady = frame_padding )
@@ -695,6 +722,25 @@ def change_focus(event):
695722 border_color = frame_border_color , hover_color = button_highlight_color , height = button_height , command = break_mechanism )
696723break_btn .place (anchor = "s" , relx = 0.5 , rely = 0.9 )
697724
725+ subject_pomodoro_frame = ctk .CTkFrame (main_frame , height = (HEIGHT - button_height * 1.5 ), width = frame_width )
726+ subject_pomodoro_frame .grid (row = 0 , column = 2 )
727+ subject_pomodoro_frame .pack_propagate (False )
728+
729+ subject_frame = ctk .CTkFrame (subject_pomodoro_frame , fg_color = frame_color , height = 175 , width = frame_width , corner_radius = 10 )
730+ subject_frame .pack (padx = frame_padding , pady = frame_padding )
731+ subject_label = ctk .CTkLabel (subject_frame , text = "Subject" , font = (font_family , font_size ), text_color = font_color )
732+ subject_label .place (anchor = "nw" , relx = 0.05 , rely = 0.05 )
733+ subject_selection = ctk .CTkComboBox (subject_frame , values = ["Mathematics" , "Science" , "Literature" , "History" , "Geography" , "Language Arts" , "Foreign Languages" , "Social Studies" ,
734+ "Economics" , "Computer Science" , "Psychology" , "Philosophy" , "Art" , "Music" , "Physical Education" , "Other" ],
735+ state = "readonly" , width = 200 , height = 30 , dropdown_font = (font_family , int (font_size * 0.75 )), variable = default_subject ,
736+ font = (font_family , int (font_size )), fg_color = border_frame_color , button_color = border_frame_color )
737+ subject_selection .place (anchor = "center" , relx = 0.5 , rely = 0.45 )
738+ subject_btn = ctk .CTkButton (subject_frame , text = "Save" , font = (font_family , font_size ), text_color = button_font_color , fg_color = button_color , hover_color = button_highlight_color ,
739+ height = button_height , command = set_subject )
740+ subject_btn .place (anchor = "s" , relx = 0.5 , rely = 0.9 )
741+ pomodoro_frame = ctk .CTkFrame (subject_pomodoro_frame , fg_color = frame_color , corner_radius = 10 , width = frame_width , height = 220 )
742+ pomodoro_frame .pack (padx = frame_padding , pady = frame_padding )
743+
698744#DATA UI ROW
699745data_frame = ctk .CTkFrame (main_frame , fg_color = frame_color , corner_radius = 10 , width = WIDTH - 10 , height = button_height * 2 )
700746data_frame .place (anchor = "s" , relx = 0.5 , rely = 0.985 )
@@ -739,35 +785,40 @@ def change_focus(event):
739785history_data_frame = ctk .CTkScrollableFrame (history_frame_frame , fg_color = "transparent" , width = WIDTH - (frame_padding * 4 ), height = 520 + frame_padding * 2 )
740786history_data_frame .pack (padx = frame_padding , pady = frame_padding )
741787
742- start_label = ctk .CTkLabel (history_label_frame , text = "Start" , font = (font_family , int (font_size * 1.5 )), text_color = font_color , fg_color = "transparent" )
788+ start_label = ctk .CTkLabel (history_label_frame , text = "Start" , font = (font_family , int (font_size * 1.25 )), text_color = font_color , fg_color = "transparent" )
743789start_label .grid (row = 0 , column = 0 , padx = widget_padding_x , pady = widget_padding_y )
744- end_label = ctk .CTkLabel (history_label_frame , text = "End" , font = (font_family , int (font_size * 1.5 )), text_color = font_color , fg_color = "transparent" )
790+ end_label = ctk .CTkLabel (history_label_frame , text = "End" , font = (font_family , int (font_size * 1.25 )), text_color = font_color , fg_color = "transparent" )
745791end_label .grid (row = 0 , column = 1 , padx = widget_padding_x , pady = widget_padding_y )
746- duration_label = ctk .CTkLabel (history_label_frame , text = "Duration" , font = (font_family , int (font_size * 1.5 )), text_color = font_color , fg_color = "transparent" )
792+ duration_label = ctk .CTkLabel (history_label_frame , text = "Duration" , font = (font_family , int (font_size * 1.25 )), text_color = font_color , fg_color = "transparent" )
747793duration_label .grid (row = 0 , column = 2 , padx = widget_padding_x , pady = widget_padding_y )
748- break_label = ctk .CTkLabel (history_label_frame , text = "Break" , font = (font_family , int (font_size * 1.5 )), text_color = font_color , fg_color = "transparent" )
794+ break_label = ctk .CTkLabel (history_label_frame , text = "Break" , font = (font_family , int (font_size * 1.25 )), text_color = font_color , fg_color = "transparent" )
749795break_label .grid (row = 0 , column = 3 , padx = widget_padding_x , pady = widget_padding_y )
750796
751797start_frame = ctk .CTkFrame (history_data_frame , fg_color = "transparent" )
752798start_frame .grid (row = 1 , column = 0 , padx = frame_padding , pady = frame_padding )
753- start_text = ctk .CTkLabel (start_frame , font = (font_family , int ( font_size * 1.25 ) ), text_color = font_color )
799+ start_text = ctk .CTkLabel (start_frame , font = (font_family , font_size ), text_color = font_color )
754800start_text .pack (padx = widget_padding_x * 3 , pady = widget_padding_y )
755801
756802end_frame = ctk .CTkFrame (history_data_frame , fg_color = "transparent" )
757803end_frame .grid (row = 1 , column = 1 , padx = frame_padding , pady = frame_padding )
758- end_text = ctk .CTkLabel (end_frame , text = "" , font = (font_family , int ( font_size * 1.25 ) ), text_color = font_color )
804+ end_text = ctk .CTkLabel (end_frame , text = "" , font = (font_family , font_size ), text_color = font_color )
759805end_text .pack (padx = widget_padding_x * 3 , pady = widget_padding_y )
760806
761807duration_frame = ctk .CTkFrame (history_data_frame , fg_color = "transparent" )
762808duration_frame .grid (row = 1 , column = 2 , padx = frame_padding , pady = frame_padding )
763- duration_text = ctk .CTkLabel (duration_frame , text = "" , font = (font_family , int ( font_size * 1.25 ) ), text_color = font_color )
809+ duration_text = ctk .CTkLabel (duration_frame , text = "" , font = (font_family , font_size ), text_color = font_color )
764810duration_text .pack (padx = widget_padding_x * 3 , pady = widget_padding_y )
765811
766812break_frame = ctk .CTkFrame (history_data_frame , fg_color = "transparent" )
767813break_frame .grid (row = 1 , column = 3 , padx = frame_padding , pady = frame_padding )
768- break_text = ctk .CTkLabel (break_frame , text = "" , font = (font_family , int ( font_size * 1.25 ) ), text_color = font_color )
814+ break_text = ctk .CTkLabel (break_frame , text = "" , font = (font_family , font_size ), text_color = font_color )
769815break_text .pack (padx = widget_padding_x * 3 , pady = widget_padding_y )
770816
817+ subject_frame = ctk .CTkFrame (history_data_frame , fg_color = "transparent" )
818+ subject_frame .grid (row = 1 , column = 4 , padx = frame_padding , pady = frame_padding )
819+ subject_text = ctk .CTkLabel (subject_frame , text = "" , font = (font_family , font_size ), text_color = font_color )
820+ subject_text .pack (padx = widget_padding_x * 3 , pady = widget_padding_y )
821+
771822settings_tab = ctk .CTkFrame (tab_frame , width = tab_frame_width , height = tab_height * 0.8 , fg_color = tab_color )
772823settings_tab .place (relx = 0.5 , rely = 1 , anchor = "s" )
773824settings_btn = ctk .CTkButton (settings_tab , text = "Settings" , font = (tab_font_family , 22 * tab_height / 50 , tab_font_weight ), text_color = font_color ,
@@ -792,7 +843,7 @@ def change_focus(event):
792843 border_color = frame_border_color , hover_color = button_highlight_color , height = button_height , command = reset_data , width = 450 )
793844reset_data_btn .pack ()
794845
795- widget_list = [goal_btn , timer_btn , break_btn , save_data_btn , color_btn , reset_data_btn ]
846+ widget_list = [goal_btn , timer_btn , break_btn , save_data_btn , color_btn , reset_data_btn , subject_btn ]
796847
797848load_color (color , widget_list , progressbar )
798849
0 commit comments