As we know Tkinter is used to create a variety of GUI (Graphical User Interface) applications. In this article we will learn how to create a Digital clock using Tkinter.
Prerequisites:
-> Python functions
-> Tkinter basics (Label Widget)
-> Time module
Using Label widget from Tkinter and time module :
In the following application, we are going to use Label widget and also going to use time module which we will use to retrieve system’s time.
Below is the implementation:
# 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() |
Output:

Recommended Posts:
- Create digital clock using Python-Turtle
- PyQt5 - Create a digital clock
- Python | Create a stopwatch using clock object in kivy using .kv file
- Python | Create a stopwatch Using Clock Object in kivy
- Create Analog Clock using PyQt5 in Python
- Python Tkinter | Create different type of lines using Canvas class
- Python Tkinter | Create different shapes using Canvas class
- Python | Create a GUI Marksheet using Tkinter
- Create a Yes/No Message Box in Python using tkinter
- Create MySQL Database Login Page in Python using Tkinter
- Create First GUI Application using Python-Tkinter
- Create Copy-Move GUI using Tkinter in Python
- Create Countdown Timer using Python-Tkinter
- Create Table Using Tkinter
- Python Tkinter | Create LabelFrame and add widgets to it
- Create Find and Replace features in Tkinter Text Widget
- Draw Clock Design using Turtle in Python
- Python | time.clock() method
- Color game using Tkinter in Python
- Python | Message Encode-Decode using Tkinter
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

