forked from greyson-newton/Muon_Sim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStopwatch.py
More file actions
28 lines (24 loc) · 803 Bytes
/
Stopwatch.py
File metadata and controls
28 lines (24 loc) · 803 Bytes
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
import tkinter as tk
from time import time
class Stopwatch:
def __init__(self, timeElapsed, paused, window, button):
self.timeElapsed = timeElapsed
self.window = window
self.paused = paused
print('out')
def toggle(self):
if self.paused:
self.paused = False
#self.button.config(text='Stop')
self.oldtime = time()
self.run_timer()
else:
self.paused = True
self.oldtime = time()
def run_timer(self):
if self.paused:
return
delta = int(time() - self.oldtime)
timestr = '{:02}:{:02}'.format(*divmod(delta, 60))
self.timeElapsed.config(text=timestr)
self.timeElapsed.after(1000, self.run_timer)