Skip to content

Commit b443f26

Browse files
committed
update timer.py
Added a pomodoro break calculation
1 parent 67dd42b commit b443f26

File tree

2 files changed

+53
-29
lines changed

2 files changed

+53
-29
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11

22
__pycache__/styles.cpython-312.pyc
3+
test.py

timer.py

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ def change_color(color, highlight_color, widget_list, progressbar):
611611
widget.configure(fg_color=color, hover_color=highlight_color)
612612
progressbar.configure(progress_color = color)
613613

614-
def set_color(widget):
614+
def choose_color(widget):
615615
global color, graph_color, pie_color_1, pie_color_2, pie_color_3, pie_color_4, pie_color_5, pie_color_6, pie_color_7, day_duration_list, day_name_list
616616
worksheet["T1"].value = color
617617
workbook.save(data_file)
@@ -636,7 +636,25 @@ def set_subject():
636636
worksheet["Q1"].value = current_subject
637637
workbook.save(data_file)
638638
print("Subject set and saved.")
639-
639+
640+
641+
def calculate_pomodoro_breaks(goal):
642+
y = 0
643+
pomodoro_breaks = []
644+
while True:
645+
if goal > 25:
646+
y += 1
647+
if y % 4 != 0:
648+
pomodoro_breaks.append(5)
649+
else:
650+
pomodoro_breaks.append(20)
651+
print(f"{goal} - {goal-25}, {pomodoro_breaks[y-1]}")
652+
goal -= 25
653+
else:
654+
print(f"{goal} - 0")
655+
return pomodoro_breaks
656+
657+
640658
#------------------------------------------------------------------------------GUI------------------------------------------------------------------------------#
641659
#clock_image = ctk.CTkImage(light_image=Image.open("images/clock.png"), size=(image_width, image_height))
642660
def change_focus(event):
@@ -790,41 +808,46 @@ def change_focus(event):
790808
history_data_frame = ctk.CTkScrollableFrame(history_frame_frame, fg_color="transparent", width=WIDTH-(frame_padding*4), height=520+frame_padding*2)
791809
history_data_frame.pack(padx=frame_padding)
792810

793-
start_label = ctk.CTkLabel(history_label_frame, text="Start", font=(font_family, int(font_size*1.25)), text_color=font_color, fg_color="transparent")
794-
start_label.grid(row=0, column=0, padx=(WIDTH-(frame_padding*4))/11)
795-
end_label = ctk.CTkLabel(history_label_frame, text="End", font=(font_family, int(font_size*1.25)), text_color=font_color, fg_color="transparent")
796-
end_label.grid(row=0, column=1, padx=(WIDTH-(frame_padding*4))/11)
797-
duration_label = ctk.CTkLabel(history_label_frame, text="Duration", font=(font_family, int(font_size*1.25)), text_color=font_color, fg_color="transparent")
798-
duration_label.grid(row=0, column=2, padx=widget_padding_x)
799-
break_label = ctk.CTkLabel(history_label_frame, text="Break", font=(font_family, int(font_size*1.25)), text_color=font_color, fg_color="transparent")
800-
break_label.grid(row=0, column=3, padx=(WIDTH-(frame_padding*4))/37)
801-
subject_label = ctk.CTkLabel(history_label_frame, text="Subject", font=(font_family, int(font_size*1.25)), text_color=font_color, fg_color="transparent")
802-
subject_label.grid(row=0, column=4, padx=(WIDTH-(frame_padding*4))/17)
803-
804-
start_frame = ctk.CTkFrame(history_data_frame, fg_color="transparent")
805-
start_frame.grid(row=1, column=0, padx=frame_padding)
811+
start_label = ctk.CTkLabel(history_label_frame, text="Start", font=(font_family, int(font_size*1.25)), text_color=font_color, fg_color="transparent", width=(WIDTH-(frame_padding*4))/5)
812+
start_label.grid(row=0, column=0)
813+
end_label = ctk.CTkLabel(history_label_frame, text="End", font=(font_family, int(font_size*1.25)), text_color=font_color, fg_color="transparent", width=(WIDTH-(frame_padding*4))/5)
814+
end_label.grid(row=0, column=1)
815+
duration_label = ctk.CTkLabel(history_label_frame, text="Duration", font=(font_family, int(font_size*1.25)), text_color=font_color, fg_color="transparent", width=(WIDTH-(frame_padding*4))/5)
816+
duration_label.grid(row=0, column=2)
817+
break_label = ctk.CTkLabel(history_label_frame, text="Break", font=(font_family, int(font_size*1.25)), text_color=font_color, fg_color="transparent", width=(WIDTH-(frame_padding*4))/5)
818+
break_label.grid(row=0, column=3)
819+
subject_label = ctk.CTkLabel(history_label_frame, text="Subject", font=(font_family, int(font_size*1.25)), text_color=font_color, fg_color="transparent", width=(WIDTH-(frame_padding*4))/5)
820+
subject_label.grid(row=0, column=4)
821+
822+
start_frame = ctk.CTkFrame(history_data_frame, fg_color="transparent", width=(WIDTH-(frame_padding*4))/5)
823+
start_frame.grid(row=1, column=0)
824+
start_frame.pack_propagate(False)
806825
start_text = ctk.CTkLabel(start_frame, font=(font_family, font_size), text_color=font_color)
807-
start_text.pack(padx=widget_padding_x*3)
826+
start_text.pack()
808827

809-
end_frame = ctk.CTkFrame(history_data_frame, fg_color="transparent")
810-
end_frame.grid(row=1, column=1, padx=frame_padding)
828+
end_frame = ctk.CTkFrame(history_data_frame, fg_color="transparent", width=(WIDTH-(frame_padding*4))/5)
829+
end_frame.grid(row=1, column=1)
830+
end_frame.pack_propagate(False)
811831
end_text = ctk.CTkLabel(end_frame, text="", font=(font_family, font_size), text_color=font_color)
812-
end_text.pack(padx=widget_padding_x*3)
832+
end_text.pack()
813833

814-
duration_frame = ctk.CTkFrame(history_data_frame, fg_color="transparent")
815-
duration_frame.grid(row=1, column=2, padx=frame_padding)
834+
duration_frame = ctk.CTkFrame(history_data_frame, fg_color="transparent", width=(WIDTH-(frame_padding*4))/5)
835+
duration_frame.grid(row=1, column=2)
836+
duration_frame.pack_propagate(False)
816837
duration_text = ctk.CTkLabel(duration_frame, text="", font=(font_family, font_size), text_color=font_color)
817-
duration_text.pack(padx=widget_padding_x*3)
838+
duration_text.pack()
818839

819-
break_frame = ctk.CTkFrame(history_data_frame, fg_color="transparent")
820-
break_frame.grid(row=1, column=3, padx=frame_padding)
840+
break_frame = ctk.CTkFrame(history_data_frame, fg_color="transparent", width=(WIDTH-(frame_padding*4))/5)
841+
break_frame.grid(row=1, column=3)
842+
break_frame.pack_propagate(False)
821843
break_text = ctk.CTkLabel(break_frame, text="", font=(font_family, font_size), text_color=font_color)
822-
break_text.pack(padx=widget_padding_x*3)
844+
break_text.pack()
823845

824-
subject_frame = ctk.CTkFrame(history_data_frame, fg_color="transparent")
825-
subject_frame.grid(row=1, column=4, padx=frame_padding)
846+
subject_frame = ctk.CTkFrame(history_data_frame, fg_color="transparent", width=(WIDTH-(frame_padding*4))/5)
847+
subject_frame.grid(row=1, column=4)
848+
subject_frame.pack_propagate(False)
826849
subject_text = ctk.CTkLabel(subject_frame, text="", font=(font_family, font_size), text_color=font_color)
827-
subject_text.pack(padx=widget_padding_x*3)
850+
subject_text.pack()
828851

829852
settings_tab = ctk.CTkFrame(tab_frame, width=tab_frame_width, height=tab_height*0.8, fg_color=tab_color)
830853
settings_tab.place(relx=0.5, rely=1, anchor="s")
@@ -841,7 +864,7 @@ def change_focus(event):
841864
dropdown_font=(font_family, int(font_size*0.75)), font=(font_family, int(font_size)), fg_color=border_frame_color, button_color=border_frame_color)
842865
color_dropdown.place(anchor="center", relx=0.5, rely=0.45)
843866
color_btn = ctk.CTkButton(color_select_frame, text="Save", font=(font_family, font_size), text_color=button_font_color, fg_color=button_color, hover_color=button_highlight_color,
844-
height=button_height, command=lambda: set_color(color_dropdown))
867+
height=button_height, command=lambda: choose_color(color_dropdown))
845868
color_btn.place(anchor="s", relx=0.5, rely=0.9)
846869

847870
reset_btn_frame = ctk.CTkFrame(settings_frame, fg_color=tab_color)

0 commit comments

Comments
 (0)