In this article we have designed a Digital Clock in
Python
usingTkinter
To know more about
Python Programming
Click Here
The code starts by importing the necessary modules. The first module is the
tkinter library
, which provides basic functionality for creatinggraphical user interfaces (GUIs)
. Next, thestrftime function
is imported to retrieve system time. Next, a window is created and given a title of “Clock.” A function calledtime()
is then created to display the current time on thelabel
widget. This function uses thestrftime()
function to format the time string according to system conventions. The last part of this code sets up styling for the label widget so that it will look nicer. Finally, an instance of Label is created and placed at the center of the window. The code creates a window and assigns it the title “Clock”. Thetime()
function is then called to display the current time on the label widget. Thelbl.config()
function is used to set the text of the label widget. Theafter()
function is used to delay displaying the time for 1000 milliseconds. Finally, the style of the label widget is modified withlbl.pack()
.We also attach the
exe
Version of it with this project repo.
You can also convert this program in to exe file. You just neet to install Babel
for that
To install Babel
follow the given command billow
pip install Babel
And also follow the given code to all your project files like this
from babel.numbers import *
from babel.dates import *
Babel
is used to fix images in exe
version of your code.
You also need Pyinstaller
. This library converts the .py
scripts to exe
.
To install Pyinstaller
follow the given command billow.
pip install pyinstaller
You are all set to go. Open your native terminal and run the following command to convert your .py
script into exe
file.
pyinstaller --onefile -w --hiddenimport=babel.numbers filename.py
# in this project the filename.py is PythonClock.py
To get more interesting projects follow our GitHub page at Here
To get more interesting projects follow our Bitbucket page at Here