Skip to content

Commit cfd13f3

Browse files
Updating Source Code
1 parent 2f86b58 commit cfd13f3

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

stopwatch-gui.py

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import tkinter as tk
2+
from datetime import datetime
3+
counter = 66600
4+
running = False
5+
def counter_label(wel_label):
6+
def count():
7+
if running:
8+
global counter
9+
if counter==66600:
10+
display="Starting..."
11+
else:
12+
tt = datetime.fromtimestamp(counter)
13+
string = tt.strftime("%H:%M:%S")
14+
display=string
15+
16+
wel_label['text']=display
17+
wel_label.after(1000, count)
18+
counter += 1
19+
count()
20+
def Start(wel_label):
21+
global running
22+
running=True
23+
counter_label(wel_label)
24+
Time_Start['state']='disabled'
25+
Time_Stop['state']='normal'
26+
Time_Reset['state']='normal'
27+
def Stop():
28+
global running
29+
Time_Start['state']='normal'
30+
Time_Stop['state']='disabled'
31+
Time_Reset['state']='normal'
32+
running = False
33+
def Reset(wel_label):
34+
global counter
35+
counter=66600
36+
if running==False:
37+
Time_Reset['state']='disabled'
38+
wel_label['text']='Welcome!'
39+
else:
40+
wel_label['text']='Starting the Time'
41+
root = tk.Tk()
42+
root.title("Gui-Stopwatch")
43+
root.minsize(width=600, height=600)
44+
root['bg']='Black'
45+
wel_label = tk.Label(root, text="Welcome!", fg="Pink",bg="Black", font=("Comic Sans Ms", 60 ))
46+
wel_label.pack()
47+
frame = tk.Frame(root)
48+
Time_Start = tk.Button(frame, text='Start', width=6,bg="Dark Green",fg='White', command=lambda:Start(wel_label),font=("Comic Sans Ms", 30 ))
49+
Time_Stop = tk.Button(frame, text='Stop',bg="Red",fg='White' , width=6,state='disabled', command=Stop,font=("Comic Sans Ms", 30))
50+
Time_Reset = tk.Button(frame, text='Reset',bg="Yellow",fg='Black' , width=6, state='disabled', command=lambda:Reset(wel_label),font=("Comic Sans Ms", 30))
51+
frame.pack(anchor = 'center',pady=5)
52+
Time_Start.pack(side="left")
53+
Time_Stop.pack(side ="left")
54+
Time_Reset.pack(side="left")
55+
root.mainloop()

0 commit comments

Comments
 (0)