GUI Digital Clock Using Python

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.

Introduction:

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

Code:
				
					# 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

library management system using python with source code using Python GUI Tkinter (Graphical User Interface) How to Run the code: Introduction:  Imagine …

Space Shooter Game Using Python with source code Overview: A space shooter game typically involves controlling a spaceship to navigate through space …

Hotel Management System Using Python with source code Introduction: Welcome to our blog post introducing a helpful tool for hotels: the Tkinter-based …

Student Management System Using Python Introduction: The Student Management System is a comprehensive software solution designed to streamline the process of managing …

Billing Management System using Python introduction: The Billing software using python is a simple yet effective Python application designed to facilitate the …

Medical Management System using Python with Complete Source code [By using Flask Framework] Introduction Hospital Management System The Hospital Management System is …

More Python Projects
Get Huge Discounts

All Coding Handwritten Notes

Browse Handwritten Notes