Skip to content

Commit b517f1b

Browse files
committed
Save and Load Color Theme
1 parent 98381e3 commit b517f1b

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

timer.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
start_time = ""
3636
goal = 0
3737
default_choice = ctk.StringVar(value="1 hour")
38-
default_color = ctk.StringVar(value="Orange")
3938
color = ""
4039

4140

@@ -86,7 +85,7 @@ def customize_excel(worksheet):
8685
worksheet["W6"].value = saturday_duration
8786
worksheet["W7"].value = sunday_duration
8887

89-
worksheet["T1"].variable = color
88+
worksheet["T1"].value = color
9089

9190
worksheet["A1"].font = Font(bold=True, size=14)
9291
worksheet["B1"].font = Font(bold=True, size=14)
@@ -236,7 +235,7 @@ def collect_data():
236235
global data_amount, date_list, duration_list
237236
global monday_amount, tuesday_amount, wednesday_amount, thursday_amount, friday_amount, saturday_amount, sunday_amount
238237
global monday_duration, tuesday_duration, wednesday_duration, thursday_duration, friday_duration, saturday_duration, sunday_duration
239-
global color
238+
global color, default_color
240239

241240
data_amount = int(worksheet["Z1"].value)
242241

@@ -257,8 +256,9 @@ def collect_data():
257256
sunday_duration = int(worksheet["W7"].value)
258257

259258
color = worksheet["T1"].value
260-
if color == "":
259+
if color == None:
261260
color = "Orange"
261+
default_color = ctk.StringVar(value=color)
262262

263263
day_duration_list = [monday_duration, tuesday_duration, wednesday_duration, thursday_duration, friday_duration, saturday_duration, sunday_duration]
264264
day_name_list = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
@@ -470,6 +470,8 @@ def set_streak(goal, timer_time, progressbar):
470470
def load_color(color, widget_list, progressbar):
471471
highlight_colors = {"Orange": orange_highlight_color, "Green": green_highlight_color, "Blue": blue_highlight_color}
472472
highlight_color = highlight_colors[color]
473+
colors = {"Orange": orange_button_color, "Green": green_button_color, "Blue": blue_button_color}
474+
color = colors[color]
473475
change_color(color, highlight_color, widget_list, progressbar)
474476

475477

@@ -481,6 +483,9 @@ def change_color(color, highlight_color, widget_list, progressbar):
481483

482484
def set_color(widget):
483485
global color
486+
worksheet["T1"].value = color
487+
workbook.save(data_file)
488+
print("Color saved.")
484489
color = widget.get()
485490
colors = {"Orange": orange_button_color, "Green": green_button_color, "Blue": blue_button_color}
486491
highlight_colors = {"Orange": orange_highlight_color, "Green": green_highlight_color, "Blue": blue_highlight_color}
@@ -606,6 +611,8 @@ def change_focus(event):
606611

607612
widget_list = [goal_btn, timer_btn, break_btn, save_data_btn, color_btn, reset_data_btn]
608613

614+
load_color(color, widget_list, progressbar)
615+
609616
WINDOW.bind_all("<Button>", change_focus)
610617

611618
WINDOW.protocol("WM_DELETE_WINDOW", save_on_quit)

0 commit comments

Comments
 (0)