GUI Digital Clock Using Python with Source Code

Introduction:

In this Project, I will show you. How to Create Graphical User Interface of Digital Clock and How to Design your clock beautifully. We are Using Tkinter, which is a framework of Python Programming Language. In which we can design your outer part of the project or an application. tkinter mainly provides a good user experience and is understandable by a non-technical person easily.

Now we start work with Tkinter for creating our digital clock. In this project, we can customize the background, font, etc. As your need.

A digital clock is a type of clock that displays the time digitally (i.e. in numerals or other symbols). We get time from CLI ( Command Line Interface) but that is not much attractive GUI( Graphical User Interface) is much more attractive as well interactive. Now we build a GUI of a digital clock in python implemented using Tkinter & Time packages/module. Before writing code some requirements for GUI 

Import Tkinter:

First, we need to install the Tkinter module. If you do not have this module already installed in your system then you can install the same using the pip package manager:

C:\User\admin> pip install tkinter

How To Run The Code : 

Step 1: Open any Python Code Editor
Step 2: Make a Python file digital-clock.py
Step 3: Copy the code & Paste it 
Step 4: Run the file digital-clock.py and your Program will run

Source Code:

Get Discount on Top Educational Courses

Brand NameDiscount InformationCoupon Codes Link
Educative.io20% discount on Educative courses and plans
W3Schools20% discount on W3Schools courses
KodeKloud10% discount on KodeKloud courses and plans
GeeksforGeeks30% discount on GeeksforGeeks courses
Target Test Prep20% discount on Target Test Prep
Coding Ninjas₹5000 discount on Coding Ninjas courses
Skillshare40% discount on Skillshare
DataCamp50% discount on DataCamp
365 Data Science57% discount on 365 Data Science Plans
Get SmarterFlat 20% discount on Get Smarter courses
SmartKeedaFlat 40% discount on SmartKeeda courses
StackSocial20% discount on StackSocial courses
				
					# importing whole module------
from tkinter import * 

  
# importing strftime function to capturing system's time

from time import strftime
  
# creating tkinter window
digital_clock = Tk()
digital_clock.geometry("600x300")
digital_clock.title('Digital Clock')
  
# Display time on the label using this function
def time():
    string = strftime('%H:%M:%S %p')  # %h=hour ,%M=Minute ,%S=second ,p%=am or pm according to the given time value 
    lable.config(text = string)
    lable.after(1000, time)
  
#Increase the user experience designning the label widget 

lable = Label(digital_clock, font = ('calibri', 40, 'bold'),
            background = '#AA0000',
            foreground = 'white')

  
# clock at the centre of the tkinter window

lable.pack(anchor = 'center')
time()  #function calling

mainloop()
				
			

Explanation:

Step 1: Firstly import Tkinter & strftime from time

Step 2: Create Tkinter window & give the title

Step 3: Define the label font, background, foreground

Step 4: Pack the label at the center using anchor 

Step 5: Create a function in which string store hour, Minute, Second, AM, or PM

Step 6: Config text to string & define microsecond

Step 7: Call the function

Output:

Find More Projects

electronics Store website using html CSS and JavaScript Introduction Hello coders, welcome to another new project. As you know our today’s project …

Digital Marketing Agency website Using HTML, CSS and JavaScript Introduction Hello coders, welcome to another new blog. Today in this project we’ll …

Fruit Slicer Game Using HTML CSS And JavaScript Introduction Hey coders, welcome to another new blog. Today in this blog we’ve created …

Event Organizers Website Using Html Css And JavaScript Introduction Hello coders, welcome to another new blog. As you know that our today’s …

Shape Clicker Game Using HTML CSS And JavaScript Introduction Hey coders, welcome to another new blog. Today in this article we’ve made …

responsive College Website Using Html CSS & JavaScript Introduction Hello coders, welcome to another new blog. Today in this blog post we’ll …

Get Huge Discounts
More Python Projects