-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathstenography.py
53 lines (43 loc) · 1.4 KB
/
stenography.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
import tkinter as tk
import time
def start():
global running
running = True
start_button['state'] = 'disabled'
stop_button['state'] = 'active'
update()
def stop():
global running
running = False
start_button['state'] = 'active'
stop_button['state'] = 'disabled'
def reset():
global running, elapsed_time
running = False
elapsed_time = 0
time_label.config(text="00:00:00")
start_button['state'] = 'active'
stop_button['state'] = 'disabled'
def update():
if running:
global elapsed_time
elapsed_time += 1
hours, remainder = divmod(elapsed_time, 3600)
minutes, seconds = divmod(remainder, 60)
time_str = f"{hours:02d}:{minutes:02d}:{seconds:02d}"
time_label.config(text=time_str)
time_label.after(1000, update)
running = False
elapsed_time = 0
root = tk.Tk()
root.title("Cool Stopwatch")
time_label = tk.Label(root, text="00:00:00", font=('Helvetica', 48))
time_label.pack(padx=20, pady=20)
start_button = tk.Button(root, text="Start", font=('Helvetica', 16), command=start)
start_button.pack(side="left", padx=10)
stop_button = tk.Button(root, text="Stop", font=('Helvetica', 16), command=stop)
stop_button.pack(side="left", padx=10)
reset_button = tk.Button(root, text="Reset", font=('Helvetica', 16), command=reset)
reset_button.pack(side="left", padx=10)
stop_button['state'] = 'disabled'
root.mainloop()