-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstopwatch.py
More file actions
52 lines (48 loc) · 1.29 KB
/
stopwatch.py
File metadata and controls
52 lines (48 loc) · 1.29 KB
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
import tkinter as Tkinter
counter =-1
runnning=False
def counter_label(label):
def count():
if running:
global counter
if counter==-1:
display="STARTING..."
else:
display=str(counter)
label['text']=display
label.after(1000,count)
counter+=1
count()
def Start(label):
global running
running=True
counter_label(label)
start['state']='disabled'
stop['state']='normal'
reset['state']='normal'
def Stop():
global running
start['state']='normal'
stop['state']='disabled'
reset['state']='normal'
running=False
def Reset(lable):
global counter
counter=-1
if running==False:
reset['state']='disabled'
label['text']="WELCOME!"
else:
label['text']='STARTING...'
root=Tkinter.Tk()
root.title("STOPWATCH")
root.minsize(width=250,height=70)
label=Tkinter.Label(root,text="WELCOME!",fg="black",font="Verdana 30 bold")
label.pack()
start=Tkinter.Button(root,text='START',width=15,command=lambda:Start(label))
start.pack()
stop=Tkinter.Button(root,text="STOP",width=15,state="disabled",command=Stop)
stop.pack()
reset=Tkinter.Button(root,text="RESET",width=15,state="disabled",command=lambda:Reset(label))
reset.pack()
root.mainloop()