def reset(self): """resets the selected countdown""" print self.countdown_label[self.pomodoro.active_countdown][0].get() print uf.sec_to_clockface(self.pomodoro.active_countdown.countdowntime)[0] #if what's currently displayed on the gui is equal to the countdown time #then you reset to zero, so we increment the reset counter by 1 if self.countdown_label[self.pomodoro.active_countdown][0].get() == uf.sec_to_clockface(self.pomodoro.active_countdown.countdowntime)[0]: #print "it worked, increment reset counter" self.reset_counter[self.pomodoro.active_countdown] = 1 #if reset has been clicked twice, everything gets fully reset to 0 if self.reset_counter[self.pomodoro.active_countdown] >= 1: self.reset_counter[self.pomodoro.active_countdown] = 0 self.pomodoro.active_countdown.countdowntime = (0,0,0,0) #when reset is clicked, timer is no longer in stop mode self.stop_state = False #reset the callback counter self.callback_counter[self.pomodoro.active_countdown] = 0 #so that the time_remaining is not < 0 self.pomodoro.reset_pomodoro() self.reset_counter[self.pomodoro.active_countdown] += 1 #have the gui display the countdown's countdowntime obtained from the countdown object #if reset was hit once, it will be the original countdowntime, if twice, it will be zero self.countdown_label[self.pomodoro.active_countdown][0].set(uf.sec_to_clockface(self.pomodoro.active_countdown.countdowntime)[0]) self.countdown_label[self.pomodoro.active_countdown][1].set("000") #the gui will display whatever the countdown time has been reset to self.actual_output[self.pomodoro.active_countdown] = uf.sec_to_list(self.pomodoro.active_countdown.countdowntime)
def print_to_countdown(self): """prints how much time is left in the countdown""" if self.pomodoro.active_countdown.timer.running: output = uf.sec_to_clockface(self.pomodoro.time_remaining()) self.countdown_label[self.pomodoro.active_countdown][0].set(output[0]) self.countdown_label[self.pomodoro.active_countdown][1].set(output[1]) #when the time is up if self.pomodoro.active_countdown.time_remaining() < 0: self.play_alert() self.manual_stop() #count a round every time a work_countdown ends, you are #counting the number of times someone has done the work portion if self.pomodoro.is_work: self.rounds_counter += 1 if self.rounds_counter == 1: self.rounds_label_text.set(str(self.rounds_counter) + " round") else: self.rounds_label_text.set(str(self.rounds_counter) + " rounds") #the following two lines are done so that you don't end up with negative #numbers on the number display on the gui self.countdown_label[self.pomodoro.active_countdown][0].set(uf.sec_to_clockface(self.pomodoro.active_countdown.countdowntime)[0]) self.countdown_label[self.pomodoro.active_countdown][1].set("000") self.toggle_countdown() self.master.after(50, self.print_to_countdown)
def clear(self): """resets both countdowns after they are stopped.""" #change stop button text from "CLEAR" to "STOP" self.stop_button.config(text = "STOP") self.stop_state = False #reset both countdowns self.pomodoro.reset_pomodoro() #set the countdown times equal to 0, because reset_pomodoro() does not do that self.pomodoro.input_times((0,0,0,0), (0,0,0,0)) #change the display back to 0's self.countdown_label[self.pomodoro.break_countdown][0].set(uf.sec_to_clockface(self.pomodoro.break_countdown.countdowntime)[0]) self.countdown_label[self.pomodoro.break_countdown][1].set("000") self.countdown_label[self.pomodoro.work_countdown][0].set(uf.sec_to_clockface(self.pomodoro.work_countdown.countdowntime)[0]) self.countdown_label[self.pomodoro.work_countdown][1].set("000") #change the self.actual_outputs back to 0 self.actual_output[self.pomodoro.break_countdown] = uf.sec_to_list(self.pomodoro.break_countdown.countdowntime) self.actual_output[self.pomodoro.work_countdown] = uf.sec_to_list(self.pomodoro.work_countdown.countdowntime) #make sure both break and work time buttons are raised self.work_button.config(relief="raised") self.break_button.config(relief="raised") #make neither countdown be the active countdown self.pomodoro.active_countdown = None #have to reset callback counter self.callback_counter[self.pomodoro.work_countdown] = 0 self.callback_counter[self.pomodoro.break_countdown] = 0 #reset the rounds counter self.rounds_counter = 0 #reset the rounds counter on the gui self.rounds_label_text.set(str(self.rounds_counter) + " rounds")