Jan-25-2019, 04:45 PM
Hello,
I'm building a chronometer as my first Python project, and I got it working to the point where when i press the STOP button on the GUI, the time that has passed since i pressed the START button is displayed both on the GUI and on the terminal.
What I have to do now is display the time that has passed since i pressed the START button on the GUI every 200ms or so.
I don't know if it's possible to do that due to my program's design. If it's possible, could someone point me in the right direction?
Here is my code so far:
I'm building a chronometer as my first Python project, and I got it working to the point where when i press the STOP button on the GUI, the time that has passed since i pressed the START button is displayed both on the GUI and on the terminal.
What I have to do now is display the time that has passed since i pressed the START button on the GUI every 200ms or so.
I don't know if it's possible to do that due to my program's design. If it's possible, could someone point me in the right direction?
Here is my code so far:
from tkinter import * import datetime def start_fun(): global start_time start_time = datetime.datetime.now() print(start_time) def stop_fun(): global stop_time stop_time = datetime.datetime.now() print(stop_time) delta() update_label() def delta(): global delta_time delta_time = stop_time - start_time print(delta_time) def update_label(): tempo = delta_time lb.config(text=str(tempo)) root = Tk() root.geometry("300x50") root.title("vChronometer") lb = Label(root, text="0:00:00.000000", font=(None, 14)) lb.place(x=100, y=15) start = Button(root, width=8, text="START", command=start_fun) start.place(x=0,y=0) stop = Button(root, width=8, text="STOP", command=stop_fun) stop.place(x=0,y=25) root.mainloop()