Write a Python GUI to create a digital clock with a tkinter to display the time.
Slip 2 Q 2
CODE :
from tkinter import *
from tkinter.ttk import *
from time import strftime
root = Tk()
root.title('Clock')
def time():
string = strftime('%H:%M:%S %p')
lbl.config(text = string)
lbl.after(1000, time)
lbl = Label(root, font = ('calibri', 40, 'bold'),
background = 'purple',
foreground = 'white')
lbl.pack(anchor = 'center')
time()
mainloop()
No comments:
Post a Comment