示例#1
0
    def reset(self):
        print("timer is being reset")
        self.keep_toggling = False
        #uf.return_bg_color([self.root, self.label, self.small_label])
        
        if self.reset_counter >= 1:
            self.reset_counter = 0
            self.mycountdown.countdowntime = (0,0,0,0)
            
        self.reset_counter += 1
        print("this is how many times reset has been clicked {}".format(self.reset_counter))
        self.start_button.grid(row=1, column=0)

        self.mycountdown.reset_countdown()
        self.countdown_time = uf.seconds_to_tuple(self.mycountdown.countdowntime)
        self.on_state = False
        self.start_button.config(text = "START")
        self.click_counter = 0
        self.output = "{:02d}:{:02d}:{:02d}".format(self.countdown_time[0], self.countdown_time[1], self.countdown_time[2])
        self.small_output = "000"
        self.new_output = uf.string_to_list(self.output)
        self.new_output = uf.list_to_tuple(self.new_output)
        self.print_elapsed()
        print("here is output after being reset {}".format(self.output))
        print("this is the current countdown time {}".format(self.countdown_time))
示例#2
0
 def callback(self, label):
     #If timer is running, don't do anything
     if self.mycountdown.timer.running:
         print("timer is currently running")
         return
         
     #print "Click {}".format(self.click_counter)
     
     #this ensures that when reset is clicked after a number is clicked, the original countdown
     # time reappears
     self.reset_counter = 0
     
     # "hh:mm:ss" (what has been inputted by user using keypad) -> [h,h,m,m,s,s] 
     self.new_output = uf.string_to_list(self.output)
     # take off first element in new_output, and add label (keypad number pressed) to the end
     self.new_output.pop(0)
     self.new_output.append(label)
     
     #count up 1, to keep track of how many spaces in hh:mm:ss have been filled
     self.click_counter += 1
     
     #resets after the first h in hh:mm:ss has been filled (or rightmost number has moved all the way to leftmost spot)
     if self.click_counter > 6:
         self.output = self.new_output
         self.reset()
         return
     
     #[h,h,m,m,s,s] -> (hh,mm,ss, ms (always zero)) 
     self.new_output = uf.list_to_tuple(self.new_output)
     
     
     self.output = "{:02d}:{:02d}:{:02d}".format(self.new_output[0], self.new_output[1], self.new_output[2])
     self.textvar.set(self.output)
 
     return self.output