From 98bec7d6584e0337443345587da14660d9f9cb98 Mon Sep 17 00:00:00 2001 From: Aayush shah <58617484+ios-shah@users.noreply.github.com> Date: Sun, 3 Oct 2021 11:14:51 +0530 Subject: [PATCH] Create clock.py This is a Python code for making a digital analog clock using Python by using the module Tktinker created by Aayush Shah --- clock.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 clock.py diff --git a/clock.py b/clock.py new file mode 100644 index 00000000..5c3899e8 --- /dev/null +++ b/clock.py @@ -0,0 +1,32 @@ +#creating digital clock pn py using tktinker by aayush shah +# 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 = 'centre') +time() + +mainloop()