From f647bb6121af04ab6ee2ada142963b3d4a4993f0 Mon Sep 17 00:00:00 2001 From: Meenakshy Bindu Suresh Date: Wed, 5 Oct 2022 16:03:11 +0530 Subject: [PATCH] Create DigitalClock.py Digital Clock using tkinter --- DigitalClock.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 DigitalClock.py diff --git a/DigitalClock.py b/DigitalClock.py new file mode 100644 index 00000000..8fba4bdc --- /dev/null +++ b/DigitalClock.py @@ -0,0 +1,31 @@ +# importing whole module +from tkinter import * +from tkinter.ttk import * + +# importing strftime function to +# retrieve system's time +from time import strftime + +# creating tkinter window +root = Tk() +root.title('Clock') + +# This function is used to +# display time on the label +def time(): + string = strftime('%H:%M:%S %p') + lbl.config(text = string) + lbl.after(1000, time) + +# Styling the label widget so that clock +# will look more attractive +lbl = Label(root, font = ('calibri', 40, 'bold'), + background = 'purple', + foreground = 'white') + +# Placing clock at the centre +# of the tkinter window +lbl.pack(anchor = 'center') +time() + +mainloop()