Skip to content

Commit d9ee8cc

Browse files
committed
update
1 parent e05e0ab commit d9ee8cc

8 files changed

Lines changed: 324 additions & 92 deletions

File tree

.gitignore

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

22
__pycache__/styles.cpython-312.pyc
33
test.py
4+
*.pyc
Binary file not shown.
-493 Bytes
Binary file not shown.
Binary file not shown.

Version 1.0.0/Package/data_management.py

Lines changed: 120 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import os
21
import datetime
32

4-
import openpyxl as op
53
from openpyxl.styles import Font
4+
from .styles import *
5+
6+
import customtkinter as ctk
67

78
class DataManager:
89
def __init__(self, App, timer_manager, workbook, worksheet):
@@ -14,20 +15,28 @@ def __init__(self, App, timer_manager, workbook, worksheet):
1415

1516

1617
def initialize_variables(self):
18+
self.day_name_list = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
1719
self.date_list = []
1820
self.duration_list = []
1921
self.total_duration = 0
22+
self.graph_color = "#f38064"
23+
self.widget_list = []
2024

2125

2226
def initialize_new_file_variables(self):
2327
self.goal_amount = 0
2428
self.data_amount = 0
29+
self.monday_duration = self.tuesday_duration = self.wednesday_duration = self.thursday_duration = self.friday_duration = self.saturday_duration = self.sunday_duration = 0
30+
self.color_name = "Orange"
31+
self.save_color(self.color_name)
2532

2633

2734
def collect_data(self):
2835
self.data_amount = int(self.worksheet["Z2"].value)
2936
self.goal_amount = int(self.worksheet["R2"].value)
3037

38+
self.collect_day_data()
39+
3140
print("Data collected.")
3241

3342

@@ -44,11 +53,10 @@ def data_to_variable(self):
4453

4554
def save_data(self):
4655
self.initialize_variables()
56+
self.save_weekday()
57+
self.save_color(self.color_name)
4758

4859
self.data_amount += 1
49-
50-
self.timer_time = self.timer_manager.timer_time
51-
self.break_time = self.timer_manager.break_time
5260

5361
self.stop_time = datetime.datetime.now()
5462

@@ -68,8 +76,10 @@ def write_to_excel(self):
6876
self.worksheet["A" + str((self.data_amount + 1))].value = self.start_time.strftime("%d/%m/%Y %H:%M")
6977
self.worksheet["B" + str((self.data_amount + 1))].value = self.stop_time.strftime("%d/%m/%Y %H:%M")
7078
self.worksheet["C" + str((self.data_amount + 1))].value = self.duration
71-
self.worksheet["D" + str((self.data_amount + 1))].value = self.break_time/60
79+
self.worksheet["D" + str((self.data_amount + 1))].value = self.timer_manager.break_time/60
80+
7281
self.worksheet["R2"].value = self.goal_amount
82+
7383
self.worksheet["Z2"].value = self.data_amount
7484
self.workbook.save(self.app.data_file)
7585

@@ -83,25 +93,40 @@ def customize_excel(self):
8393
self.worksheet["R1"].value = "Goals reached:"
8494
self.worksheet["R2"].value = self.goal_amount
8595

86-
self.worksheet["A1"].font = Font(bold=True, size=14)
87-
self.worksheet["B1"].font = Font(bold=True, size=14)
88-
self.worksheet["C1"].font = Font(bold=True, size=14)
89-
self.worksheet["D1"].font = Font(bold=True, size=14)
90-
self.worksheet["E1"].font = Font(bold=True, size=14)
96+
self.worksheet["T2"].value = self.color_name
97+
98+
self.worksheet["W2"].value = self.monday_duration
99+
self.worksheet["W3"].value = self.tuesday_duration
100+
self.worksheet["W4"].value = self.wednesday_duration
101+
self.worksheet["W5"].value = self.thursday_duration
102+
self.worksheet["W6"].value = self.friday_duration
103+
self.worksheet["W7"].value = self.saturday_duration
104+
self.worksheet["W8"].value = self.sunday_duration
91105

92106
self.worksheet["Z1"].value = "Data amount: "
93107
self.worksheet["Z1"].font = Font(bold=True, size=14)
94108
self.worksheet["Z2"].value = self.data_amount
109+
110+
self.style_excel()
111+
95112
self.workbook.save(self.app.data_file)
96113
print("Excel customized.")
97114

98115

116+
def style_excel(self):
117+
self.worksheet["A1"].font = Font(bold=True, size=14)
118+
self.worksheet["B1"].font = Font(bold=True, size=14)
119+
self.worksheet["C1"].font = Font(bold=True, size=14)
120+
self.worksheet["D1"].font = Font(bold=True, size=14)
121+
self.worksheet["E1"].font = Font(bold=True, size=14)
122+
123+
99124
def get_start_time(self):
100125
self.start_time = datetime.datetime.now()
101126

102127

103128
def calculate_duration(self):
104-
duration = self.timer_time - self.break_time
129+
duration = self.timer_manager.timer_time - self.timer_manager.break_time
105130
if duration < 0:
106131
duration = 0
107132
else:
@@ -110,9 +135,7 @@ def calculate_duration(self):
110135

111136

112137
def increase_goal_streak(self):
113-
print("AAA")
114138
self.goal_amount += 1
115-
print(self.goal_amount)
116139

117140

118141
def reset_data(self, workbook, worksheet):
@@ -124,4 +147,86 @@ def reset_data(self, workbook, worksheet):
124147

125148
self.workbook.save(self.app.data_file)
126149

127-
print("Data reset.")
150+
print("Data reset.")
151+
152+
153+
def clear_graph_lists(self):
154+
self.date_list.clear()
155+
self.duration_list.clear()
156+
157+
158+
def collect_day_data(self):
159+
monday_duration = int(self.worksheet["W2"].value)
160+
tuesday_duration = int(self.worksheet["W3"].value)
161+
wednesday_duration = int(self.worksheet["W4"].value)
162+
thursday_duration = int(self.worksheet["W5"].value)
163+
friday_duration = int(self.worksheet["W6"].value)
164+
saturday_duration = int(self.worksheet["W7"].value)
165+
sunday_duration = int(self.worksheet["W8"].value)
166+
167+
day_duration_list = [monday_duration, tuesday_duration, wednesday_duration, thursday_duration, friday_duration, saturday_duration, sunday_duration]
168+
return day_duration_list
169+
170+
171+
def save_weekday(self):
172+
duration = self.calculate_duration()
173+
weekday_today = datetime.datetime.now().weekday()
174+
175+
match weekday_today:
176+
case 0:
177+
self.monday_duration += duration
178+
self.worksheet["W2"].value = self.monday_duration
179+
case 1:
180+
self.tuesday_duration += duration
181+
self.worksheet["W3"].value = self.tuesday_duration
182+
case 2:
183+
self.wednesday_duration += duration
184+
self.worksheet["W4"].value = self.wednesday_duration
185+
case 3:
186+
self.thursday_duration += duration
187+
self.worksheet["W5"].value = self.thursday_duration
188+
case 4:
189+
self.friday_duration += duration
190+
self.worksheet["W6"].value = self.friday_duration
191+
case 5:
192+
self.saturday_duration += duration
193+
self.worksheet["W7"].value = self.saturday_duration
194+
case 6:
195+
self.sunday_duration += duration
196+
self.worksheet["W8"].value = self.sunday_duration
197+
198+
self.workbook.save(self.app.data_file)
199+
print("Weekday saved.")
200+
201+
202+
def set_color(self, color_dropdown):
203+
color_name = color_dropdown.get()
204+
print("Color set.")
205+
self.save_color(color_name)
206+
207+
208+
def save_color(self, color_name):
209+
self.worksheet["T2"].value = color_name
210+
self.load_color()
211+
212+
213+
def load_color(self):
214+
color_name = self.worksheet["T2"].value
215+
self.app.color_dropdown.configure(variable=ctk.StringVar(value=color_name))
216+
colors = {"Orange": [orange_button_color, orange_highlight_color, orange_pie_colors],
217+
"Green": [green_button_color, green_highlight_color, green_pie_colors],
218+
"Blue": [blue_button_color, blue_highlight_color, blue_pie_colors]}
219+
220+
self.color = colors[color_name][0]
221+
self.highlight_color = colors[color_name][1]
222+
self.pie_colors = colors[color_name][2]
223+
self.graph_color = self.color
224+
print("Color loaded.")
225+
self.change_color(self.color, self.highlight_color)
226+
227+
228+
def change_color(self, color, highlight_color):
229+
for widget in self.widget_list:
230+
widget.configure(fg_color=color, hover_color=highlight_color)
231+
self.app.progressbar.configure(progress_color = color)
232+
print("Color changed.")

Version 1.0.0/Package/styles.py

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,35 +53,19 @@
5353
#ORANGE
5454
orange_button_color = "#f38064"
5555
orange_highlight_color = "#f5937a"
56-
pie_color_orange_1 = "#f38064"
57-
pie_color_orange_2 = "#eb856b"
58-
pie_color_orange_3 = "#e28a73"
59-
pie_color_orange_4 = "#da8f7c"
60-
pie_color_orange_5 = "#d29484"
61-
pie_color_orange_6 = "#c9998d"
62-
pie_color_orange_7 = "#c19e95"
56+
orange_pie_colors = ["#f38064", "#eb856b", "#e28a73", "#da8f7c", "#d29484", "#c9998d", "#c19e95"]
57+
6358

6459
#GREEN
6560
green_button_color = "#93f263"
6661
green_highlight_color = "#a3f47b"
67-
pie_color_green_1 = "#96ea6c"
68-
pie_color_green_2 = "#99e274"
69-
pie_color_green_3 = "#9cd97d"
70-
pie_color_green_4 = "#9ed185"
71-
pie_color_green_5 = "#a1c88d"
72-
pie_color_green_6 = "#a4c096"
73-
pie_color_green_7 = "#a7b79e"
62+
green_pie_colors = ["#96ea6c", "#99e274", "#9cd97d", "#9ed185", "#a1c88d", "#a4c096", "#a7b79e"]
63+
7464

7565
#BLUE
7666
blue_button_color = "#63c2f2"
7767
blue_highlight_color = "#7bccf4"
78-
pie_color_blue_1 = "#63c2f2"
79-
pie_color_blue_2 = "#6cc0ea"
80-
pie_color_blue_3 = "#74bde2"
81-
pie_color_blue_4 = "#9ed185"
82-
pie_color_blue_5 = "#7dbad9"
83-
pie_color_blue_6 = "#85b6d1"
84-
pie_color_blue_7 = "#8db4c8"
68+
blue_pie_colors = ["#63c2f2", "#6cc0ea", "#74bde2", "#9ed185", "#7dbad9", "#85b6d1", "#8db4c8"]
8569

8670
image_width = 30
87-
image_height = 30
71+
image_height = 30

Version 1.0.0/Package/timer_management.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ def timer_mechanism(self, timer_button, break_button, time_display_label):
2121
self.break_running = False
2222
timer_button.configure(text="Stop")
2323
break_button.configure(text="Start")
24-
self.update_time()
24+
self._update_time()
2525

2626
elif self.timer_running:
2727
self.timer_running = False
2828
timer_button.configure(text="Start")
2929

3030

31-
def update_time(self):
31+
def _update_time(self):
3232
if self.timer_running:
3333
self.timer_time += 1
3434
self.time_display_label.configure(text=str(datetime.timedelta(seconds=self.timer_time)))
3535
self.app.reach_goal(self.timer_time)
36-
self.window.after(1000, self.update_time)
36+
self.window.after(1000, self._update_time)
3737

3838

3939
def break_mechanism(self, break_button, timer_button, break_display_label):
@@ -43,14 +43,14 @@ def break_mechanism(self, break_button, timer_button, break_display_label):
4343
self.timer_running = False
4444
break_button.configure(text="Stop")
4545
timer_button.configure(text="Start")
46-
self.update_break_time()
46+
self._update_break_time()
4747
elif self.break_running:
4848
self.break_running = False
4949
self.break_button.configure(text="Start")
5050

5151

52-
def update_break_time(self):
52+
def _update_break_time(self):
5353
if self.break_running:
5454
self.break_time += 1
5555
self.break_display_label.configure(text=str(datetime.timedelta(seconds=self.break_time)))
56-
self.window.after(1000, self.update_break_time)
56+
self.window.after(1000, self._update_break_time)

0 commit comments

Comments
 (0)