Thursday, 20 January 2022

Python-slip2-b-Write Python GUI program to create a digital clock with Tkinter to display the time.

Write Python GUI program to create a digital clock with Tkinter to display the time.

 import time

from tkinter import *

canvas = Tk()

canvas.title("Digital Clock")

canvas.geometry("350x200")

canvas.resizable(1,1)

label = Label(canvas, font=("arial", 20, 'bold'), bg="pink", fg="white", bd =10)

label.grid(row =0, column=1)

def digitalclock():

   text_input = time.strftime("%H:%M:%S")

   label.config(text=text_input)

   label.after(200, digitalclock)

digitalclock()

canvas.mainloop()