9
9
import customtkinter as ctk
10
10
from styles import *
11
11
from matplotlib .ticker import MaxNLocator
12
- from win11toast import toast
12
+ from winotify import Notification
13
13
import random
14
14
from matplotlib .ticker import FuncFormatter
15
15
41
41
color = "Orange"
42
42
default_color = ctk .StringVar (value = color )
43
43
notification_limit = False
44
+ default_subject = ctk .StringVar (value = "Other" )
45
+ current_subject = "Other"
46
+ subject = ""
44
47
45
48
46
49
main_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):
73
76
worksheet ["B1" ].value = "End:"
74
77
worksheet ["C1" ].value = "Duration:"
75
78
worksheet ["D1" ].value = "Break:"
76
- worksheet ["E1" ].value = "Streak :"
79
+ worksheet ["E1" ].value = "Subject :"
77
80
78
81
worksheet ["U1" ].value = "Monday:"
79
82
worksheet ["U2" ].value = "Tuesday:"
@@ -252,7 +255,7 @@ def my_format(pct):
252
255
253
256
254
257
def 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
256
259
global monday_amount , tuesday_amount , wednesday_amount , thursday_amount , friday_amount , saturday_amount , sunday_amount
257
260
global monday_duration , tuesday_duration , wednesday_duration , thursday_duration , friday_duration , saturday_duration , sunday_duration
258
261
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():
277
280
278
281
goal_amount = int (worksheet ["R1" ].value )
279
282
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
+
280
288
color = worksheet ["T1" ].value
281
289
if color == None :
282
290
color = "Orange"
@@ -375,7 +383,7 @@ def update_break_time():
375
383
#------------------------------------------------------------------------------DATA-----------------------------------------------------------------------------#
376
384
def save_data ():
377
385
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
379
387
global break_running , break_time , break_btn , break_label
380
388
381
389
if timer_time < 60 :
@@ -386,6 +394,9 @@ def save_data():
386
394
notification_limit = False
387
395
timer_running , break_running = False , False
388
396
397
+ if subject == "" or subject == None :
398
+ subject = "Other"
399
+
389
400
duration = calculate_duration ()
390
401
391
402
data_amount += 1
@@ -397,6 +408,7 @@ def save_data():
397
408
worksheet ["B" + str ((data_amount + 1 ))].value = stop_time .strftime ("%d/%m/%Y %H:%M" )
398
409
worksheet ["C" + str ((data_amount + 1 ))].value = duration
399
410
worksheet ["D" + str ((data_amount + 1 ))].value = break_time / 60
411
+ worksheet ["E" + str ((data_amount + 1 ))].value = subject
400
412
401
413
timer_btn .configure (text = "Start" )
402
414
break_btn .configure (text = "Start" )
@@ -406,7 +418,6 @@ def save_data():
406
418
workbook .save (data_file )
407
419
408
420
if timer_time / 60 >= goal :
409
- progressbar .set (1 )
410
421
goal_amount += 1
411
422
worksheet ["R1" ].value = goal_amount
412
423
times_studied_label .configure (text = goal_amount )
@@ -454,7 +465,8 @@ def reset_data():
454
465
455
466
def send_notification (title , message ):
456
467
global notification_limit
457
- toast (title , message )
468
+ toast = Notification (app_id = APPNAME , title = title , msg = message )
469
+ toast .show ()
458
470
notification_limit = True
459
471
print ("Notification " + title + " sent." )
460
472
@@ -519,6 +531,7 @@ def load_history():
519
531
end_history = ""
520
532
duration_history = ""
521
533
break_history = ""
534
+ subject_history = ""
522
535
if data_amount > 0 :
523
536
for data in range (data_amount + 1 , 1 , - 1 ):
524
537
start_history += str (worksheet ["A" + str (data )].value )
@@ -529,15 +542,20 @@ def load_history():
529
542
duration_history += "\n "
530
543
break_history += str (round (worksheet ["D" + str (data )].value )) + "m"
531
544
break_history += "\n "
545
+ subject_history += str (worksheet ["E" + str (data )].value )
546
+ subject_history += "\n "
547
+
532
548
start_text .configure (text = start_history )
533
549
end_text .configure (text = end_history )
534
550
duration_text .configure (text = duration_history )
535
551
break_text .configure (text = break_history )
552
+ subject_text .configure (text = subject_history )
536
553
else :
537
554
start_text .configure (text = "-" )
538
555
end_text .configure (text = "-" )
539
556
duration_text .configure (text = "-" )
540
557
break_text .configure (text = "-" )
558
+ subject_text .configure (text = "-" )
541
559
542
560
543
561
def set_goal ():
@@ -609,6 +627,15 @@ def set_color(widget):
609
627
highlight_color = highlight_colors [color ]
610
628
graph_color = c
611
629
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." )
612
639
613
640
#------------------------------------------------------------------------------GUI------------------------------------------------------------------------------#
614
641
#clock_image = ctk.CTkImage(light_image=Image.open("images/clock.png"), size=(image_width, image_height))
@@ -668,7 +695,7 @@ def change_focus(event):
668
695
669
696
timer_break_frame = ctk .CTkFrame (main_frame , height = (HEIGHT - button_height * 1.5 ), width = frame_width )
670
697
timer_break_frame .grid (row = 0 , column = 1 )
671
- timer_break_frame .propagate (False )
698
+ timer_break_frame .pack_propagate (False )
672
699
673
700
timer_frame = ctk .CTkFrame (timer_break_frame , fg_color = frame_color , corner_radius = 10 , width = frame_width , height = 220 )
674
701
timer_frame .pack (padx = frame_padding , pady = frame_padding )
@@ -695,6 +722,25 @@ def change_focus(event):
695
722
border_color = frame_border_color , hover_color = button_highlight_color , height = button_height , command = break_mechanism )
696
723
break_btn .place (anchor = "s" , relx = 0.5 , rely = 0.9 )
697
724
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
+
698
744
#DATA UI ROW
699
745
data_frame = ctk .CTkFrame (main_frame , fg_color = frame_color , corner_radius = 10 , width = WIDTH - 10 , height = button_height * 2 )
700
746
data_frame .place (anchor = "s" , relx = 0.5 , rely = 0.985 )
@@ -739,35 +785,40 @@ def change_focus(event):
739
785
history_data_frame = ctk .CTkScrollableFrame (history_frame_frame , fg_color = "transparent" , width = WIDTH - (frame_padding * 4 ), height = 520 + frame_padding * 2 )
740
786
history_data_frame .pack (padx = frame_padding , pady = frame_padding )
741
787
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" )
743
789
start_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" )
745
791
end_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" )
747
793
duration_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" )
749
795
break_label .grid (row = 0 , column = 3 , padx = widget_padding_x , pady = widget_padding_y )
750
796
751
797
start_frame = ctk .CTkFrame (history_data_frame , fg_color = "transparent" )
752
798
start_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 )
754
800
start_text .pack (padx = widget_padding_x * 3 , pady = widget_padding_y )
755
801
756
802
end_frame = ctk .CTkFrame (history_data_frame , fg_color = "transparent" )
757
803
end_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 )
759
805
end_text .pack (padx = widget_padding_x * 3 , pady = widget_padding_y )
760
806
761
807
duration_frame = ctk .CTkFrame (history_data_frame , fg_color = "transparent" )
762
808
duration_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 )
764
810
duration_text .pack (padx = widget_padding_x * 3 , pady = widget_padding_y )
765
811
766
812
break_frame = ctk .CTkFrame (history_data_frame , fg_color = "transparent" )
767
813
break_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 )
769
815
break_text .pack (padx = widget_padding_x * 3 , pady = widget_padding_y )
770
816
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
+
771
822
settings_tab = ctk .CTkFrame (tab_frame , width = tab_frame_width , height = tab_height * 0.8 , fg_color = tab_color )
772
823
settings_tab .place (relx = 0.5 , rely = 1 , anchor = "s" )
773
824
settings_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):
792
843
border_color = frame_border_color , hover_color = button_highlight_color , height = button_height , command = reset_data , width = 450 )
793
844
reset_data_btn .pack ()
794
845
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 ]
796
847
797
848
load_color (color , widget_list , progressbar )
798
849
0 commit comments