Skip to content

Commit dc2eb34

Browse files
committed
Update
1 parent 6a731a1 commit dc2eb34

8 files changed

Lines changed: 143 additions & 47 deletions

File tree

Package/data_management.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
from collections import Counter
2+
13
import datetime
24
from openpyxl.styles import Font
35

46
import customtkinter as ctk
57
import darkdetect
6-
78
from .styles import *
89
from .note_management import NotesManager
910

@@ -23,6 +24,11 @@ def initialize_variables(self) -> None:
2324
self.date_list = []
2425
self.duration_list = []
2526
self.total_duration = 0
27+
self.break_list = []
28+
self.total_break_duration = 0
29+
self.hours_list = []
30+
self.subject_list = []
31+
self.average_time = "00:00"
2632
self.graph_color = "#f38064"
2733
self.graph_bg_color = graph_bg_color
2834
self.graph_fg_color = graph_fg_color
@@ -67,6 +73,24 @@ def data_to_variable(self) -> None:
6773
self.duration_list.append(round(self.worksheet["C" + str(data)].value))
6874

6975
self.total_duration = sum(self.duration_list)
76+
77+
self.create_total_data()
78+
79+
80+
def create_total_data(self):
81+
def get_sec(time: str) -> int:
82+
"""Get seconds from time."""
83+
h, m = time.split(':')
84+
return int(h) * 3600 + int(m) * 60
85+
86+
for data in range(2, self.data_amount + 2):
87+
self.break_list.append(float(self.worksheet["D" + str(data)].value))
88+
self.hours_list.append(get_sec((self.worksheet["A" + str(data)].value.split(" ")[1])))
89+
self.subject_list.append(self.worksheet["E" + str(data)].value)
90+
91+
self.total_break_duration = sum(self.break_list)
92+
self.average_time = str(datetime.timedelta(seconds=(round(sum(self.hours_list) / len(self.hours_list)))))[:5]
93+
self.most_common_subject = Counter(self.subject_list).most_common(1)[0][0]
7094

7195

7296
def save_data(self) -> None:
@@ -162,7 +186,7 @@ def get_start_time(self) -> None:
162186

163187

164188
def calculate_duration(self) -> float:
165-
duration = self.timer_manager.timer_time - self.timer_manager.break_time
189+
duration = self.timer_manager.timer_time
166190
if duration < 0:
167191
duration = 0
168192
else:
@@ -246,6 +270,8 @@ def save_autobreak(self, frequency: str, duration: str, switch: str) -> None:
246270

247271
self.workbook.save(self.app.data_file)
248272

273+
print("Autobreak saved.")
274+
249275
self.load_autobreak()
250276

251277

@@ -269,6 +295,8 @@ def load_autobreak(self):
269295

270296
self.app.WINDOW.after(0, self.app.auto_break)
271297

298+
print("Autobreak loaded.")
299+
272300

273301
def set_color(self, color_dropdown) -> None:
274302
self.color_name = color_dropdown.get()

Package/note_management.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def __init__(self, app, data_manager):
88
self.data_manager = data_manager
99

1010
def create_task(self, index):
11-
self.frame = ctk.CTkFrame(self.app.notes_data_frame, width=WIDTH + frame_padding, fg_color=(light_frame_color, frame_color), height=button_height + frame_padding * 2)
11+
self.frame = ctk.CTkFrame(self.app.notes_data_frame, width=WIDTH + frame_padding * 2, fg_color=(light_frame_color, frame_color), height=button_height + frame_padding * 2)
1212
self.frame.pack(pady=frame_padding/2)
1313
self.frame.grid_propagate(False)
1414

@@ -27,16 +27,17 @@ def title_text(title: str) -> str:
2727
title.grid(row=0, column=0, padx=widget_padding_x)
2828
date = ctk.CTkLabel(self.frame, text=str(self.data_manager.worksheet["N" + str(index)].value), font=(font_family, font_size*1.25),
2929
text_color=(light_font_color, font_color), anchor="center", height=button_height + frame_padding * 2)
30-
date.place(anchor="center", relx=0.75, rely=0.5)
30+
date.place(anchor="center", relx=0.5, rely=0.5)
3131

3232
button_frame = ctk.CTkFrame(self.frame, fg_color="transparent")
33-
button_frame.place(anchor="center", rely=0.5, relx=0.925)
33+
button_frame.place(anchor="center", rely=0.5, relx=0.825)
3434

35-
open_button = ctk.CTkButton(button_frame, image=self.app.open_icon, text="", height=button_height, fg_color=self.data_manager.color, hover_color=self.data_manager.highlight_color, font=(font_family, font_size), text_color=button_font_color, width=button_height,
36-
command=lambda: self._open_notes_text(str(self.data_manager.worksheet["N" + str(index)].value), str(self.data_manager.worksheet["O" + str(index)].value), str(self.data_manager.worksheet["P" + str(index)].value), index))
35+
open_button = ctk.CTkButton(button_frame, text="Open", height=button_height, fg_color=self.data_manager.color, hover_color=self.data_manager.highlight_color, font=(font_family, font_size), text_color=button_font_color,
36+
command=lambda: self._open_notes_text(str(self.data_manager.worksheet["N" + str(index)].value), str(self.data_manager.worksheet["O" + str(index)].value), str(self.data_manager.worksheet["P" + str(index)].value), index)
37+
,anchor="center")
3738
open_button.grid(row=0, column=0, padx=widget_padding_x)
38-
delete_button = ctk.CTkButton(button_frame, image=self.app.delete_icon, text="", height=button_height, fg_color=self.data_manager.color, hover_color=self.data_manager.highlight_color, font=(font_family, font_size), text_color=button_font_color,
39-
command=lambda: self.delete_task(index), width=button_height)
39+
delete_button = ctk.CTkButton(button_frame, text="Delete", height=button_height, fg_color=self.data_manager.color, hover_color=self.data_manager.highlight_color, font=(font_family, font_size), text_color=button_font_color,
40+
command=lambda: self.delete_task(index), anchor="center")
4041
delete_button.grid(row=0, column=1)
4142

4243

@@ -65,18 +66,18 @@ def _open_notes_text(self, date, title, text, index):
6566
#date_label.grid(row=0, column=0, padx=widget_padding_x, pady=widget_padding_y)
6667

6768
button_frame = ctk.CTkFrame(header_frame, fg_color="transparent")
68-
button_frame.place(anchor="center", rely=0.5, relx=0.95)
69+
button_frame.place(anchor="center", rely=0.5, relx=0.825)
6970

7071
textbox = ctk.CTkTextbox(frame, font=(font_family, font_size), text_color=(light_font_color, font_color), fg_color="transparent", width=WIDTH - frame_padding * 2, height=HEIGHT + frame_padding * 2 - 60)
7172
textbox.grid(row=1, column=0)
7273
textbox.insert("0.0", text)
7374
textbox.configure(state="disabled")
7475

75-
edit_button = ctk.CTkButton(button_frame, height=button_height, image=self.app.edit_icon, text="", fg_color=self.data_manager.color, width=button_height,
76+
edit_button = ctk.CTkButton(button_frame, height=button_height, text="Edit", fg_color=self.data_manager.color, anchor="center",
7677
hover_color=self.data_manager.highlight_color, font=(font_family, font_size), text_color=button_font_color, command=lambda: self.edit_note(index, textbox, edit_button, frame))
7778
edit_button.grid(row=0, column=1)
78-
exit_button = ctk.CTkButton(button_frame, height=button_height, image=self.app.back_icon, text="", fg_color=self.data_manager.color, command=lambda: self._exit_note(frame),
79-
hover_color=self.data_manager.highlight_color, font=(font_family, font_size), text_color=button_font_color, width=button_height)
79+
exit_button = ctk.CTkButton(button_frame, height=button_height, text="Exit", fg_color=self.data_manager.color, command=lambda: self._exit_note(frame),
80+
hover_color=self.data_manager.highlight_color, font=(font_family, font_size), text_color=button_font_color, anchor="center")
8081
exit_button.grid(row=0, column=2, padx=widget_padding_x, pady=widget_padding_y)
8182

8283

@@ -92,7 +93,7 @@ def save_note(index, frame):
9293
self.data_manager.workbook.save(self.app.data_file)
9394

9495
textbox.configure(state="normal", fg_color=(light_frame_color, frame_color))
95-
edit_button.configure(text="", image=self.app.save_icon, command=lambda: save_note(index, frame), width=button_height)
96+
edit_button.configure(command=lambda: save_note(index, frame), text="Save")
9697

9798

9899
def clear_notes(self):

Package/styles.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
main_frame_color = "#2b2b2b"
6666
light_main_frame_color = "#d4d4d4"
6767

68-
graph_height = HEIGHT / 2
69-
graph_width = (WIDTH / 2) - frame_padding * 4
68+
graph_height = (HEIGHT+((widget_padding_x+frame_padding)))/1.6 - frame_padding
69+
graph_width = int(WIDTH/1.7 - frame_padding)
7070

7171
graph_bg_color = frame_color
7272
light_graph_bg_color = light_frame_color
@@ -101,5 +101,5 @@
101101
pink_pie_colors = ["#f263d5", "#ea6cd1", "#e274cc", "#d97dc7", "#d185c2", "#c88dbd", "#c096b8"]
102102

103103

104-
icon_size = 24
104+
icon_size = 20
105105
tab_icon_size = 20

Package/timer_management.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ def timer_mechanism(self, timer_button, break_button, time_display_label):
2121
self.app.frequency_input.insert("end", self.app.data_manager.autobreak_frequency)
2222
self.app.duration_input.configure(state="disabled")
2323
self.app.duration_input.insert("end", self.app.data_manager.autobreak_duration)
24-
self.app.autobreak_button.configure(state="readonly")
24+
self.app.autobreak_button.configure(state="disabled", fg_color="grey")
25+
if self.app.autobreak_switch.get() == "On":
26+
break_button.configure(state="disabled", fg_color = "grey", command=None, hover=False)
2527

2628
self.timer_running = True
2729
self.break_running = False

icons/checkmark_icon_dark.png

20.9 KB
Loading

icons/create_note_icon_dark.png

9.12 KB
Loading

icons/play_icon_dark.png

11.4 KB
Loading

0 commit comments

Comments
 (0)