I'm coding a timer that counts minutes and seconds, and I want the timer to be able to be paused when you press enter - However, I'm using a while loop to make the timer actually count, and adding a raw_input/input would stop the loop... How would I make the two functions run dynamically - together but separate?
My code so far:
from datetime import datetime
import math
#import subprocess
import sys
import time
import os
sys.stdout.write("\x1b[8;{rows};{cols}t".format(rows=24, cols=60))
t1 = 0
t3 = 0
def space():
print(" ")
print(" ")
print(" ")
print(" ")
print(" ")
print(" ")
print(" ")
print(" ")
print(" ")
print(" ")
while t1 != 1.1:
os.system('clear')
t2 = str(t1)
t4 = str(t3)
space()
print('*')*60
print "James Balazs' Python Timer".center(60,"-")
print ("Passed time: " + t4 + " minutes and " + t2 + " seconds").center(60, " ")
print('*')*60
t1 = t1 + 1
time.sleep(1)
if t1 == 60:
t1 = 0
t3 = t3 + 1
Some unnecessary imports are because I am using a modified copy of a clock I made... So all help is much appreciated as long as I don't have to destroy the majority of my work to make this possible.