1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import time
import termios, fcntl, sys, os
import Tkinter as tk
b = True
i = 0
n = 0
a = True

### NOTE TO SELF: Find out why bool isn't changing under if statement which is under try statement


def getkey():
  fd = sys.stdin.fileno()

  oldterm = termios.tcgetattr(fd)
  newattr = termios.tcgetattr(fd)
  newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
  termios.tcsetattr(fd, termios.TCSANOW, newattr)

  oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
  fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)

  try:
        while a == True:
      global i
      global n
      global b
      n = 0
      while b == True:
        global i  
        time.sleep(1)
        i+= 1
        try:
                    c = sys.stdin.read(1)
          if c == "\n":
            print "Timer has stopped"
            a == False  
              except IOError: pass
        print i

  finally:
        termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
        fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)

  
getkey()


#if i == 2:
#  b == False