How To Make Digital Clock In Python



 In this post we are going to make a digital clock with Python, we need to install tkinter, time (time is pre installed in your computer). If you don't know how to install tkinter type "pip install tkinter" in your command prompt or terminal.

Here is the 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 = 'centre')
time()
mainloop()

Post a Comment

Previous Post Next Post