コード例 #1
0
ファイル: pomapp.py プロジェクト: andrayantelo/stopwatch-py
 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)
コード例 #2
0
ファイル: pomapp.py プロジェクト: andrayantelo/stopwatch-py
 def start(self):
     """starts the countdown (the countdown that is selected)"""
     
     self.stop_state = False
     self.stop_button.config(text = "STOP")
     
     #Set the active countdown's time to the input the user gave with the keypad
     self.pomodoro.active_countdown.countdowntime = uf.list_to_tuple(self.actual_output[self.pomodoro.active_countdown])
     self.actual_output[self.pomodoro.active_countdown] = uf.sec_to_list(self.pomodoro.active_countdown.countdowntime)
     
     self.reset_counter[self.pomodoro.active_countdown] = 0
 
    
     #won't run if there isn't a countdown time
     if self.pomodoro.active_countdown.time_remaining() <= 0:
         raise RuntimeError('Time remaining is zero, input a countdown time')
     
     
     if self.pomodoro.active_countdown.timer.running:
         self.manual_stop()
         self.print_to_countdown()
         self.start_button.config(text = "START")
         
         
     else:  
         self.pomodoro.active_countdown.start_countdown()
         self.print_to_countdown()
         self.start_button.config(text = "PAUSE")  
コード例 #3
0
ファイル: pomapp.py プロジェクト: andrayantelo/stopwatch-py
 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")