bluehost

Saturday, 27 March 2021

Creating A Digital Clock With Tkinter.

In this article, I'm going to show you how to create a simple digital clock using python and the Tkinter library.
The tutorial is very easy as it will involve little codes and at the end of the day, an attractive and working clock will be produced.
First, we start with importing some important libraries.
The program.
import sys
from tkinter import*
import time
def times()
   current_time=time.strftime("%H:%M:%S")
   clock.config(text=current_time)
   clock.after(100,times)

root=Tk()
root.geometry("500×500")
clock=Label(root, font="times 50 bold", bg="blue")
clock.grid(row=2,column=2,pady=25,padx=100)
times()
digi=Label(root, text="Digital Clock", font="times 24 bold")
digi.grid(row=0, column=2)
nota=Label(root, text="hours      minutes  seconds", font="times 15 bold")
nota.grid(row=3, column=2)


root.mainloop()

As you have seen, the codes are very few but still our clock is still working. 
What next.
Now, you can try to run this and see if it works for you. You can also create a better one than this if you wish.
Follow and subscribe to my blog for more simple python projects.

No comments:

Post a Comment

React vs Angular; Front-End Web Development

Angular and React  are two of the most popular Javascript tools for front-end development. React is a Javascript created by Meta...