-
Notifications
You must be signed in to change notification settings - Fork 0
/
stop watch.py
59 lines (54 loc) · 1.45 KB
/
stop watch.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
51
52
53
54
55
56
57
58
59
import tkinter as tink
count = -1
run = False
def var_name(mark):
def value():
if run:
global count
# Just beore starting
if count == -1:
show = "Starting"
else:
show = str(count)
mark['text'] = show
#Increment the count after
#every 1 second
mark.after(1000, value)
count += 1
value()
# While Running
def Start(mark):
global run
run = True
var_name(mark)
start['state'] = 'disabled'
stop['state'] = 'normal'
reset['state'] = 'normal'
# While stopped
def Stop():
global run
start['state'] = 'normal'
stop['state'] = 'disabled'
reset['state'] = 'normal'
run = False
# For Reset
def Reset(label):
global count
count = -1
if run == False:
reset['state'] = 'disabled'
mark['text'] = 'Welcome to @python.instructions'
else:
mark['text'] = 'Start'
base = tink.Tk()
base.title("STOPWATCH")
base.minsize(width=300, height=200)
mark = tink.Label(base, text="Welcome to @python.instructions", fg="Red", font="Times 15 bold",bg="white")
mark.pack()
start = tink.Button(base, text='Start',width=25, command=lambda: Start(mark))
stop = tink.Button(base, text='Stop', width=25, state='disabled', command=Stop)
reset = tink.Button(base, text='Reset',width=25, state='disabled', command=lambda: Reset(mark))
start.pack()
stop.pack()
reset.pack()
base.mainloop()