time - Creating a timer in python -
import time def timer(): = time.localtime(time.time()) return now[5] run = raw_input("start? > ") while run == "start": minutes = 0 current_sec = timer() #print current_sec if current_sec == 59: mins = minutes + 1 print ">>>>>>>>>>>>>>>>>>>>>", mins
i want create kind of stopwatch when minutes reach 20 minutes, brings dialog box, dialog box not problem. minutes variable not increment in code.
you can simplify whole program using time.sleep
:
import time run = raw_input("start? > ") mins = 0 # run if user types in "start" if run == "start": # loop until reach 20 minutes running while mins != 20: print ">>>>>>>>>>>>>>>>>>>>>", mins # sleep minute time.sleep(60) # increment minute total mins += 1 # bring dialog box here
Comments
Post a Comment