From d304e224f3ddb16520f4b9bce6ac33c73083d7af Mon Sep 17 00:00:00 2001 From: freeram Date: Fri, 15 Mar 2024 00:32:02 -0600 Subject: [PATCH] Add automatic break cycling config --- pomodorodiscord/src/settings_frame.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pomodorodiscord/src/settings_frame.py b/pomodorodiscord/src/settings_frame.py index c1f0871..6ed7643 100644 --- a/pomodorodiscord/src/settings_frame.py +++ b/pomodorodiscord/src/settings_frame.py @@ -31,9 +31,18 @@ def __init__(self, master): self.themes_dir = 'themes' config = load_config() + # Automatic Break Cycling + self.abcycling_var = ctk.IntVar(value=config.get("auto_break_cycling", 0)) + self.abcycling_switch = ctk.CTkCheckBox(self, text=" Automatic break cycling", border_width=2, variable=self.abcycling_var, onvalue=1, offvalue=0, command=self.change_abcycling) + self.abcycling_switch.pack(pady=(10, 0)) + + # Short Breaks Before Long Break + self.sb_before_l_entry = EntryFrame(self, "Short breaks before\nlong break (if auto cycling):", config, "short_breaks_before_long", 3, self.change_sb_before_l) + self.sb_before_l_entry.pack(pady=(10, 0)) + # Pomodoro Duration self.pomodoro_entry = EntryFrame(self, "Pomodoro Duration (mins):", config, "pomodoro_time", DEF_POMODORO_MINS, self.change_pomodoro_time) - self.pomodoro_entry.pack() + self.pomodoro_entry.pack(pady=(5, 0)) # Short Break Duration self.sb_entry = EntryFrame(self, "Short Break Duration (mins):", config, "short_break_time", DEF_SB_MINS, self.change_sb_time) @@ -68,6 +77,11 @@ def __init__(self, master): self.beep_button = ctk.CTkButton(self, text="Play", width=70, command=beep.play) self.beep_button.pack(pady=(15, 0)) + def change_abcycling(self): + config = load_config() + config["auto_break_cycling"] = self.abcycling_var.get() + save_config(config) + def change_time(self, entry, config_param): time = entry.get() if time and time > 0: @@ -75,6 +89,9 @@ def change_time(self, entry, config_param): config[config_param] = time save_config(config) + def change_sb_before_l(self): + self.change_time(self.sb_before_l_entry, "short_breaks_before_long") + def change_pomodoro_time(self): self.change_time(self.pomodoro_entry, "pomodoro_time") @@ -96,4 +113,3 @@ def change_volume(self, volume): config = load_config() config['volume'] = int(volume * 100) save_config(config) -