This is my code. I was wondering if there was a way to save the stopwatch times after they have been “stopped” to some sort of list that would open up when you open the program back up?
import tkinter as tink
count = -1
run = False
def var_name(stopwatch):
def value():
if run:
global count
# Just beore starting
if count == -1:
show = “Starting”
else:
show = str(count)
stopwatch[‘text’] = show
#Increment the count after every 1 second
stopwatch.after(1000, value)
count += 1
value()
While Running
def Start(stopwatch):
global run
run = True
var_name(stopwatch)
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’
stopwatch[‘text’] = ‘Welcome’
else:
stopwatch[‘text’] = ‘Start’
base = tink.Tk()
base.title(“Alyssa’s Stopwatch”)
base.minsize(width=300, height=200,)
stopwatch = tink.Label(base, text=“Let’s begin!”, fg="#ff5ca5", font=“Times 25 bold”,bg=“white”)
stopwatch.pack()
start = tink.Button(base, text=‘Start’,fg="#c978ff",width=25, command=lambda: Start(stopwatch))
stop = tink.Button(base, text=‘Stop’, fg="#78b0ff", width=25, state=‘disabled’, command=Stop)
reset = tink.Button(base, text=‘Reset’, fg="#92fcbb",width=25, state=‘disabled’, command=lambda: Reset(stopwatch))
start.pack()
stop.pack()
reset.pack()
base.mainloop()