-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstopWatch.py
50 lines (40 loc) · 1.28 KB
/
stopWatch.py
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
from tkinter import *
global start_time, running
start_time = 0
running = False
class App():
def reset(self):
global start_time, running
running = False
self.time.set("00.00")
def start(self):
global start_time, running
print("timer started")
start_time = time.time()
running = True
self.start_timer()
def start_timer(self):
global start_time, running
self.timer()
def stop(self):
global start_time, running
running = False
def timer(self):
global start_time
print("timer timer function called")
while(True):
if(running):
current_time = time.time()
difference = current_time - start_time
self.time.set(“{:.2f}”. format(difference))
def __init__(self):
self.root = Tk()
self.root.title("Stop Watch")
self.root.geometry("1920x1080")
self.root.resizable(False, False)
self.time = StringVar()
self.time.set("00.00")
self.lb = Label(self.root, textvariable = self.time)
self.lb.config(font=("Courier 425 bold"))
self.lb.pack(side="top")