0

I want to make a Timer, but display is 0:00:00.000000 how can change display is 0:00:00

import time, datetime
import tkinter as tk
import time, datetime



win = tk.Tk()
win.geometry('200x100+550+250')
win.title('Timer')
win.config(bg='#323232')
win.attributes('-topmos', 1)

start = datetime.datetime.now()

frame = tk.Frame()

lab = tk.Label(text='', bg='#000000', fg='#FFFFFF')
lab.pack()


def update():
    dur = datetime.datetime.now() - start
    lab.config(text=dur)
    frame.after(20, update)

Start Button : when click button will start timer

St_button = tk.Button(text='Start', command=update)
St_button.pack()

frame.mainloop()
Hypnos
  • 11
  • 3

1 Answers1

0

The obvious and easy way is

    lab.config(text=str(dur)[:7])
Tim Roberts
  • 48,973
  • 4
  • 21
  • 30