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
# 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
URL Shortener Using Python Django Introduction: Long URLs can be shortened into short, shareable links with the help of the URL Shortener …
User Authentication System Using Python Django Introduction: The implementation of safe and adaptable user authentication in Django is the main goal of …
The E-Learning System using Java with a Graphical User Interface (GUI) Introduction The E-Learning System is developed using Java (with a Graphical …
Weather App Using Python Django Introduction: When a user enters the name of a city, the Weather App retrieves current weather information. …
Quiz App Using Python Django Introduction: Users can take quizzes in a variety of subjects, see their results, and monitor their progress …
resume screener in python using python introduction The hiring process often begins with reviewing numerous resumes to filter out the most suitable …