Changeset 84123db in flowtimer
- Timestamp:
- 08/15/24 09:30:14 (9 months ago)
- Branches:
- guix
- Children:
- 729b23d
- Parents:
- 401678c
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
flowtimer/Phase.py
r401678c r84123db 1 import json 2 3 1 4 class Phase: 2 5 3 6 """ 4 5 7 This class is a representation of a single phase inside a timer 6 7 8 """ 8 9 9 10 def __init__(self, title, duration): 10 11 11 """ 12 13 12 creates the variables associated with that class 14 13 … … 18 17 :type duration: int 19 18 :param duration: Duration in seconds 20 21 19 """ 22 20 … … 26 24 self.time_left = self.duration 27 25 26 def to_json(self): 27 return json.dumps({"title": self.title, "duration": self.duration}) 28 # return json.dumps(self.__dict__) 28 29 29 30 def __str__(self): 30 31 31 """ 32 33 32 Human readable representation of all attributes 34 33 35 34 :return: human readable representation of all attributes 36 35 :rtype: String 37 38 36 """ 39 37 -
flowtimer/Schedule.py
r401678c r84123db 1 import json 2 3 1 4 class Schedule: 2 5 3 6 def __init__(self, phase_list): 4 self.progressbar = None5 7 self.currentValue = 0 6 8 self.phase_list = phase_list 7 9 self.current_phase = phase_list[0] 8 10 self.state = "initial" 11 12 def to_json(self): 13 json.dumps(self.__dict__) 9 14 10 15 def start(self): -
flowtimer/main.py
r401678c r84123db 17 17 18 18 class TimerApp(tk.Frame): 19 19 20 20 def __init__(self, parent): 21 21 22 22 super().__init__(parent) 23 23 self.parent = parent … … 25 25 self.currentValue = 0 26 26 self.default_config = pd.read_csv("default_config.csv", sep=',', header=0, 27 names=('Titel', 'Values'), index_col=False, keep_default_na=False) 27 names=('Titel', 'Values'), index_col=False, 28 keep_default_na=False) 28 29 self.photo = ImageTk.PhotoImage(file='flowtimer_startbg_new.png') 29 30 self.show_config = pd.read_csv("default_config.csv", usecols=[0, 1]) … … 36 37 s = ttk.Style() 37 38 s.theme_use('clam') 38 s.configure("orange.Horizontal.TProgressbar", troughcolor='ivory3', bordercolor='black', background='CadetBlue1', lightcolor='white', darkcolor='black') 39 s.configure("orange.Horizontal.TProgressbar", troughcolor='ivory3', 40 bordercolor='black', background='CadetBlue1', 41 lightcolor='white', darkcolor='black') 39 42 40 43 self.headline_frame = tk.Frame(self.parent, bg='white') … … 45 48 self.button_frame.pack(side='bottom', fill='both', expand=False) 46 49 47 self.label_headline = tk.Label(self.headline_frame, text=("Hochintensive Intervallarbeit"), bg='white', fg='grey', font="serif 20") 50 self.label_headline = tk.Label(self.headline_frame, 51 text=("Hochintensive Intervallarbeit"), 52 bg='white', fg='grey', font="serif 20") 48 53 self.label_headline.pack(side='left', fill='both', expand=True) 49 54 50 self.label_config = tk.LabelFrame(self.headline_frame, text="config: ", bg='white', font="serif 12") 51 self.label_config.pack(side='right', fill='both', expand=False, ipadx=20, padx=20, pady=10) 52 53 self.config_button = tk.Button(self.headline_frame, text="change config", font="courier 14", width=20, command=self.change_config) 55 self.label_config = tk.LabelFrame(self.headline_frame, text="config: ", 56 bg='white', font="serif 12") 57 self.label_config.pack(side='right', fill='both', expand=False, 58 ipadx=20, padx=20, pady=10) 59 60 self.config_button = tk.Button(self.headline_frame, text="change config", 61 font="courier 14", width=20, command=self.change_config) 54 62 self.config_button.pack(side='right', padx=10, pady=10, expand=False) 55 63 56 self.label_config_text = tk.Label(self.label_config, text=self.show_config, bg='white', font="serif 10", justify='right') 64 self.label_config_text = tk.Label(self.label_config, text=self.show_config, 65 bg='white', font="serif 10", justify='right') 57 66 self.label_config_text.pack() 58 67 … … 62 71 self.label_sequence = tk.Label(self.center_frame) 63 72 self.label_sequence.pack(side='top', fill='both', expand=True) 64 65 self.progressbar = ttk.Progressbar(self.center_frame, style="orange.Horizontal.TProgressbar", orient="horizontal",length=600, mode="determinate") 73 74 self.progressbar = ttk.Progressbar(self.center_frame, 75 style="orange.Horizontal.TProgressbar", 76 orient="horizontal", length=600, mode="determinate") 66 77 self.progressbar.pack(side='top') 67 78 68 79 self.label_duration = tk.Label(self.center_frame) 69 80 self.label_duration.pack(side='top', fill='both', expand=True) 70 71 self.start_timer_button = tk.Button(self.button_frame, text="START", font="courier 14", width=20, command=self.start) 81 82 self.start_timer_button = tk.Button(self.button_frame, text="START", 83 font="courier 14", width=20, command=self.start) 72 84 self.start_timer_button.pack(side='left', fill='both', ipady=20, expand=True) 73 85 74 self.freeze_button = tk.Button(self.button_frame, text="PLAY/PAUSE", font="courier 14", width=20, command=self.toggle_tick) 86 self.freeze_button = tk.Button(self.button_frame, text="PLAY/PAUSE", 87 font="courier 14", width=20, command=self.toggle_tick) 75 88 self.freeze_button.pack(side='left', fill='both', ipady=20, expand=True) 76 89 77 self.skip_button = tk.Button(self.button_frame, text=("SKIP"), font="courier 14", width=20, command=self.skip) 90 self.skip_button = tk.Button(self.button_frame, text=("SKIP"), 91 font="courier 14", width=20, command=self.skip) 78 92 self.skip_button.pack(side='left', fill='both', ipady=20, expand=True) 79 93 80 self.quit_button = tk.Button(self.button_frame, text="QUIT", font="courier 14", width=20, command=self.quit_app) 94 self.quit_button = tk.Button(self.button_frame, text="QUIT", 95 font="courier 14", width=20, command=self.quit_app) 81 96 self.quit_button.pack(side='left', fill='both', ipady=20, expand=True) 82 97 … … 95 110 96 111 if repeat_of_phases == 3: 97 phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3)] 112 phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), 113 copy(phase_2), copy(phase_3)] 98 114 99 115 if repeat_of_phases == 4: 100 phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3),101 copy(phase_2), copy(phase_3) ]116 phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), 117 copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3)] 102 118 103 119 if repeat_of_phases == 5: 104 phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3), 105 copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3)] 120 phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), 121 copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3), 122 copy(phase_2), copy(phase_3)] 106 123 107 124 self.repeats = repeat_of_phases … … 110 127 111 128 def tick(self): 112 129 113 130 if self.schedule.is_paused(): 114 131 return … … 121 138 self.label_sequence.config(text=("\n" + str(self.schedule.current_phase.title) + "...")) 122 139 self.label_duration.config(self.start_color(root)) 123 self.label_duration.config(text=("noch " + str(math.ceil(self.schedule.current_phase.time_left)) + " Min\n")) 140 self.label_duration.config(text=("noch " + 141 str(math.ceil(self.schedule.current_phase.time_left)) + 142 " Min\n")) 124 143 self.schedule.start() 125 144 self.schedule.tick(1) … … 132 151 self.label_sequence.config(bg=self.random_color(self.label_sequence)) 133 152 self.label_duration.config(self.random_color(root)) 134 self.label_duration.config(text=("noch " + str(math.ceil(self.schedule.current_phase.time_left)) + " Min\n"), bg=self.random_color(self.label_duration)) 153 self.label_duration.config(text=("noch " + 154 str(math.ceil(self.schedule.current_phase.time_left)) 155 + " Min\n"), bg=self.random_color(self.label_duration)) 135 156 if self.schedule.tick(1/60): 136 157 self.round_counter() 137 158 138 159 else: 139 160 self.label_sequence.configure(self.time_out_color(root)) … … 147 168 self.freeze_button['state'] = 'disabled' 148 169 self.freeze_button.config(fg="ivory3") 149 170 150 171 def start(self): 151 172 self.schedule.start() … … 154 175 self.start_timer_button.config(fg="ivory3") 155 176 self.config_button.pack_forget() 156 177 157 178 def skip(self): 158 179 self.schedule.skip() … … 160 181 if self.schedule.state == "running": 161 182 self.round_counter() 162 183 163 184 def toggle_tick(self): 164 185 if self.schedule.is_paused(): … … 177 198 def quit_app(self): 178 199 self.parent.destroy() 179 200 180 201 def random_color(self, widget): 181 202 if self.schedule.current_phase.title == "B-Phase": … … 194 215 self.label_duration.configure(fg="blue") 195 216 196 197 217 def start_color(self, widget): 198 218 self.label_sequence.configure(fg="white", font="times 72") … … 200 220 self.center_frame.configure(bg="blue") 201 221 widget.configure(bg="blue") 202 222 203 223 def time_out_color(self, widget): 204 224 widget.configure(bg="red") 205 225 206 226 def progress(self, currentValue): 207 227 self.progressbar["value"] = self.currentValue … … 214 234 if self.count < 3: 215 235 self.currentValue = 0 216 self.progress(self.currentValue + 1)236 self.progress(self.currentValue + 1) 217 237 self.progressbar.update() 218 238 self.label_config.config(text="Runde: ") 219 self.label_config_text.config(text=("1", "/", self.repeats), fg='blue',font="Times 48") 239 self.label_config_text.config(text=("1", "/", self.repeats), 240 fg='blue', font="Times 48") 220 241 if self.count >= 3 and self.count < 5: 221 self.label_config_text.config(text=("2", "/", self.repeats), fg='blue',font="Times 48") 242 self.label_config_text.config(text=("2", "/", self.repeats), 243 fg='blue', font="Times 48") 222 244 if self.count >= 5 and self.count < 7: 223 self.label_config_text.config(text=("3", "/", self.repeats), fg='blue',font="Times 48") 245 self.label_config_text.config(text=("3", "/", self.repeats), 246 fg='blue', font="Times 48") 224 247 if self.count >= 7 and self.count < 9: 225 self.label_config_text.config(text=("4", "/", self.repeats), fg='blue',font="Times 48") 248 self.label_config_text.config(text=("4", "/", self.repeats), 249 fg='blue', font="Times 48") 226 250 if self.count >= 9 and self.count < 11: 227 self.label_config_text.config(text=("5", "/", self.repeats), fg='blue',font="Times 48") 251 self.label_config_text.config(text=("5", "/", self.repeats), 252 fg='blue', font="Times 48") 228 253 229 254 def change_config(self): … … 235 260 filetypes=self.config_files) 236 261 self.user_config = pd.read_csv(self.answer, sep=',', header=0, 237 names=('Titel', 'Values'), index_col=False, keep_default_na=False) 262 names=('Titel', 'Values'), 263 index_col=False, keep_default_na=False) 238 264 self.choosed_config = pd.read_csv(self.answer, usecols=[0, 1]) 239 265 self.df = self.user_config … … 253 279 254 280 if repeat_of_phases == 3: 255 phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3)] 281 phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), 282 copy(phase_2), copy(phase_3)] 256 283 257 284 if repeat_of_phases == 4: 258 phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3), 285 phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), 286 copy(phase_2), copy(phase_3), 259 287 copy(phase_2), copy(phase_3)] 260 288 261 289 if repeat_of_phases == 5: 262 phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3), 263 copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3)] 290 phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), 291 copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3), 292 copy(phase_2), copy(phase_3)] 264 293 265 294 self.repeats = repeat_of_phases … … 267 296 self.schedule = Schedule(phase_list) 268 297 298 269 299 root = tk.Tk() 270 271 272 300 root.title("--=> flowtimer <=-- " + " date: " + date + " time: " + time) 273 301 root.geometry("1280x860")
Note:
See TracChangeset
for help on using the changeset viewer.