Python Tkinter Digital Clock With Current Date and Time GUI Desktop App Using Time and Datetime Library Full Project For Beginners

Python Tkinter Digital Clock With Current Date and Time GUI Desktop App Using Time and Datetime Library Full Project For Beginners

 

Welcome folks today in this blog post we will be building a digital clock in tkinter using time and datetime library. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to make an app.py file and copy paste the following code

 

app.py

 

from tkinter import *
from tkinter import ttk
from tkinter import font
import time
import datetime


def quit(*args):
    root.destroy()

def clock_time():

    time= datetime.datetime.now()
    time= (time.strftime("Date: %Y -%m -%d \nTime: %H:%M:%S"))
    txt.set(time)

    root.after(1000,clock_time)

root =Tk()
# root.attributes("-fullscreen", False)
root.configure(bg= "black")
root.bind("x",quit)
root.geometry("1200x400")
root.title("Digital Clock Gui By Vaibhav")
root.after(1000,clock_time)

fnt = font.Font(family = "helvetica",size=80, weight ="bold")
txt = StringVar()
lbl = ttk.Label(root,textvariable=txt, font = fnt, foreground= "white",background= "black")
lbl.place(relx=0.5,rely=0.5, anchor=CENTER)

root.mainloop()

 

 

Now if you execute the python script by typing the below command as shown below

 

python app.py

 

See also  Node.js + Python 3 Script to Find Capital of Any Country in World Using EJS Template & countryinfo Library GUI Desktop Full Project For Beginners

 

Leave a Reply