Skip to content

Commit c93f363

Browse files
committed
Added statistics Buttons With Animations
1 parent 56442a4 commit c93f363

7 files changed

Lines changed: 232 additions & 67 deletions

File tree

Package/data_management.py

Lines changed: 78 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def initialize_variables(self) -> None:
3131
self.total_break_duration = 0
3232
self.hours_list = []
3333
self.subject_list = []
34+
self.best_weekday = ""
3435
self.average_time = "00:00"
3536
self.graph_color = "#f38064"
3637
self.graph_bg_color = graph_bg_color
@@ -83,7 +84,7 @@ def data_to_variable(self) -> None:
8384
def create_total_data(self):
8485
def get_sec(time: str) -> int:
8586
"""Get seconds from time."""
86-
h, m = time.split(':')
87+
h, m = time.split(":")
8788
return int(h) * 3600 + int(m) * 60
8889

8990
for data in range(2, self.data_amount + 2):
@@ -92,8 +93,22 @@ def get_sec(time: str) -> int:
9293
self.subject_list.append(self.worksheet["E" + str(data)].value)
9394

9495
self.total_break_duration = sum(self.break_list)
95-
self.average_time = str(datetime.timedelta(seconds=(round(sum(self.hours_list) / len(self.hours_list)))))[:5]
96-
self.most_common_subject = Counter(self.subject_list).most_common(1)[0][0]
96+
try:
97+
self.average_time = str(datetime.timedelta(seconds=(round(sum(self.hours_list) / len(self.hours_list)))))[:5]
98+
except ZeroDivisionError:
99+
self.average_time = "00:00"
100+
try:
101+
self.most_common_subject = Counter(self.subject_list).most_common(1)[0][0]
102+
except IndexError:
103+
self.most_common_subject = ""
104+
def get_weekday():
105+
weekdays_dict = {}
106+
for i in range(2, 9):
107+
if self.worksheet["W" + str(i)].value != 0:
108+
weekdays_dict[self.worksheet["W" + str(i)].value] = self.day_name_list[i-2]
109+
self.best_weekday = weekdays_dict[max(weekdays_dict)]
110+
get_weekday()
111+
97112

98113

99114
def save_data(self) -> None:
@@ -442,63 +457,77 @@ def load_eye_care(self) -> None:
442457

443458

444459
def export_data(self):
445-
def change_cell_width(cell_range: tuple, width: int = 15) -> None:
460+
def change_cell_width(worksheet, cell_range: tuple, width: int = 15) -> None:
446461
start, end = cell_range
447462
for cell in range(start, end + 1):
448463
cell_letter = get_column_letter(cell)
449-
export_worksheet.column_dimensions[cell_letter].width = width
464+
worksheet.column_dimensions[cell_letter].width = width
450465

451-
def align_cells(cell_range: str):
452-
for row in export_worksheet[cell_range]:
466+
def align_cells(worksheet, cell_range: str):
467+
for row in worksheet[cell_range]:
453468
for cell in row:
454-
cell.alignment = Alignment(horizontal='center', vertical='center')
469+
cell.alignment = Alignment(horizontal="center", vertical="center")
455470

456471
export_workbook = op.Workbook()
457-
export_worksheet = export_workbook.active
458-
459-
export_worksheet.merge_cells("A1:E1")
460-
export_worksheet["A1"] = "Timer"
461-
export_worksheet["A1"].font = Font(bold=True, size=16)
462-
align_cells("A1:E1")
463-
464-
export_worksheet["A2"].value = "Start:"
465-
export_worksheet["A2"].font = Font(bold=True, size=12)
466-
export_worksheet["B2"].value = "End:"
467-
export_worksheet["B2"].font = Font(bold=True, size=12)
468-
export_worksheet["C2"].value = "Duration:"
469-
export_worksheet["C2"].font = Font(bold=True, size=12)
470-
export_worksheet["D2"].value = "Break Duration:"
471-
export_worksheet["D2"].font = Font(bold=True, size=12)
472-
export_worksheet["E2"].value = "Subject:"
473-
export_worksheet["E2"].font = Font(bold=True, size=12)
474-
change_cell_width((1, 5), 20)
475-
476-
export_worksheet.merge_cells("G1:I1")
477-
export_worksheet["G1"] = "Notes"
478-
export_worksheet["G1"].font = Font(bold=True, size=16)
479-
align_cells("G1:I1")
480-
481-
export_worksheet["G2"].value = "Date:"
482-
export_worksheet["G2"].font = Font(bold=True, size=12)
483-
export_worksheet["H2"].value = "Title:"
484-
export_worksheet["H2"].font = Font(bold=True, size=12)
485-
export_worksheet["I2"].value = "Text:"
486-
export_worksheet["I2"].font = Font(bold=True, size=12)
487-
change_cell_width((7, 9), 20)
472+
timer_worksheet = export_workbook.active
473+
timer_worksheet.title = "Timer"
474+
notes_worksheet = export_workbook.create_sheet("Notes")
475+
476+
timer_worksheet.merge_cells("A1:E1")
477+
timer_worksheet["A1"] = "Timer"
478+
timer_worksheet["A1"].font = Font(bold=True, size=16)
479+
align_cells(timer_worksheet, "A1:E1")
480+
481+
timer_worksheet["A2"].value = "Start:"
482+
timer_worksheet["A2"].font = Font(bold=True, size=14)
483+
timer_worksheet["B2"].value = "End:"
484+
timer_worksheet["B2"].font = Font(bold=True, size=14)
485+
timer_worksheet["C2"].value = "Duration:"
486+
timer_worksheet["C2"].font = Font(bold=True, size=14)
487+
timer_worksheet["D2"].value = "Break Duration:"
488+
timer_worksheet["D2"].font = Font(bold=True, size=14)
489+
timer_worksheet["E2"].value = "Subject:"
490+
timer_worksheet["E2"].font = Font(bold=True, size=14)
491+
change_cell_width(timer_worksheet, (1, 5), 20)
492+
493+
notes_worksheet.merge_cells("A1:C1")
494+
notes_worksheet["A1"] = "Notes"
495+
notes_worksheet["A1"].font = Font(bold=True, size=16)
496+
align_cells(notes_worksheet, "A1:C1")
497+
498+
notes_worksheet["A2"].value = "Date:"
499+
notes_worksheet["A2"].font = Font(bold=True, size=14)
500+
notes_worksheet["B2"].value = "Title:"
501+
notes_worksheet["B2"].font = Font(bold=True, size=14)
502+
notes_worksheet["C2"].value = "Text:"
503+
notes_worksheet["C2"].font = Font(bold=True, size=14)
504+
change_cell_width(notes_worksheet, (1, 3), 20)
488505

489506
for data in range(3, self.data_amount + 3):
490-
export_worksheet["A" + str(data)].value = self.worksheet["A" + str(data - 1)].value
491-
export_worksheet["B" + str(data)].value = self.worksheet["B" + str(data - 1)].value
492-
export_worksheet["C" + str(data)].value = str(round(self.worksheet["C" + str(data - 1)].value, 1)) + "m"
493-
export_worksheet["D" + str(data)].value = str(round(self.worksheet["D" + str(data - 1)].value, 1)) + "m"
494-
export_worksheet["E" + str(data)].value = self.worksheet["E" + str(data - 1)].value
507+
timer_worksheet["A" + str(data)].value = self.worksheet["A" + str(data - 1)].value
508+
timer_worksheet["B" + str(data)].value = self.worksheet["B" + str(data - 1)].value
509+
timer_worksheet["C" + str(data)].value = str(round(self.worksheet["C" + str(data - 1)].value, 1)) + "m"
510+
timer_worksheet["D" + str(data)].value = str(round(self.worksheet["D" + str(data - 1)].value, 1)) + "m"
511+
timer_worksheet["E" + str(data)].value = self.worksheet["E" + str(data - 1)].value
495512

513+
note_list = []
496514
for note in range(self.notes_amount + 12, 12, -1):
497-
if export_worksheet["M" + str(note-data-2)].value != "Yes":
498-
export_worksheet["G" + str(note-data-2)].value = self.worksheet["N" + str(note)].value
499-
export_worksheet["H" + str(note-data-2)].value = self.worksheet["O" + str(note)].value
500-
export_worksheet["I" + str(note-data-2)].value = self.worksheet["P" + str(note)].value
501-
export_worksheet["I" + str(note-data-2)].alignment = Alignment(wrap_text=True)
515+
if self.worksheet["M" + str(note)].value == "Yes":
516+
continue
517+
else:
518+
note_list.append(note)
519+
520+
521+
for index, note in enumerate(note_list):
522+
notes_worksheet["A" + str(index + 3)].value = self.worksheet["N" + str(note)].value
523+
notes_worksheet["A" + str(index + 3)].alignment = Alignment(horizontal="left", vertical="top")
524+
notes_worksheet["A" + str(index + 3)].font = Font(size=12)
525+
notes_worksheet["B" + str(index + 3)].value = self.worksheet["O" + str(note)].value
526+
notes_worksheet["B" + str(index + 3)].alignment = Alignment(horizontal="left", vertical="top")
527+
notes_worksheet["B" + str(index + 3)].font = Font(size=12)
528+
notes_worksheet["C" + str(index + 3)].value = self.worksheet["P" + str(note)].value
529+
notes_worksheet["C" + str(index + 3)].alignment = Alignment(horizontal="left", vertical="top", wrap_text=True)
530+
notes_worksheet.column_dimensions["C"].width = 107
502531

503532
export_workbook.save(f"{os.path.join(os.path.expanduser("~"), "Desktop")}/timer_data_{datetime.datetime.now().date().strftime("%d.%m.%Y")}.xlsx")
504533

Package/styles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
tab_frame_color = "#222222"
4545
light_tab_frame_color = "#dedede"
4646

47-
tab_highlight_color = "#333333"
47+
tab_highlight_color = "#444444"
4848
light_tab_highlight_color = "#cccccc"
4949

5050
tab_selected_color = "#343434"
@@ -65,7 +65,7 @@
6565
main_frame_color = "#2b2b2b"
6666
light_main_frame_color = "#d4d4d4"
6767

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

7171
graph_bg_color = frame_color

icons/arrow_left_icon_dark.png

4.2 KB
Loading

icons/arrow_left_icon_light.png

5.83 KB
Loading

icons/arrow_right_icon_dark.png

4.49 KB
Loading

icons/arrow_right_icon_light.png

5.8 KB
Loading

0 commit comments

Comments
 (0)