How to Create Digital Clock Using Python Tkinter

In this Python tutorial, we will see how to create a digital clock using python turtle. This digital clock can be created with the help of Graphical User interface application. This tkinter is used to create a variety of GUI( Graphical User Interface) application.

How to create digital clock using Python Tkinter

Here we are creating the digital clock for this we are using the label widget and the time module that is used to recover the system time and created a digital clock with a beautiful background and foreground color.

Block of Code:

In this Python tkinter block of code we are importing all the necessary library. Here firstly we are importing the tkinter library that gives the functionality for building the graphical user interface and using the strftime function that is imported for recovering the system time.

#How to create digital clock using Python Tkinter
# importing whole module
from tkinter import *
from tkinter.ttk import *

# importing strftime function to recover the system's time
from time import strftime
 

Check this code in the Repository from Github and you can also fork this code.

Github User Name: PythonT-Point

Block of Code:

In this python tkinter block of code, here we are creating a window and give the title to the window as Pythontpoint and then creating a function called time that is used to display the current time on the label widget.

After that uses the strftime() function that form the time string according to the system convention.

#How to create digital clock using Python Tkinter
# creating tkinter window
ws = Tk()
ws.title('Pythontpoint')
 
# This function is used to display the time on the label
 
def digitalclocktime():
    strng = strftime('%H:%M:%S %p')
    label.config(text=strng)
    label.after(1000, digitalclocktime)

Block of Code:

In this block of code we are describing the styling for the label widget that give the window a style and the clock look attractive.

Here the sample of the label is created and it is placed at the center of the window. The time() function is executed and the digital clock is created.

The whole code creates a window and the title is also given to the window. The time() function is also called to show current time on the label widget.

In this code we are using the after() function that is used to delay the displaying time for 100 milliseconds and also giving the style to the widget that is modified by label.pack()

# Style the label widget so that clock will look more attractive
label = Label(ws, font=('Times New Roman', 50, 'bold'),
            background='cyan',
            foreground='white')
# Place the clock at the center of the tkinter window
label.pack(anchor='center')
digitalclocktime()
 
mainloop()

Code:

Hereafter splitting the code and explaining how to create digital clock using Python, now we will see how the output look like after running the whole code.

# How to create digital clock using Python Tkinter
# importing whole module
from tkinter import *
from tkinter.ttk import *
 
# importing strftime function to recover the system's time
from time import strftime
 
# creating tkinter window
ws = Tk()
ws.title('Pythontpoint')
 
# This function is used to display the time on the label
 
def digitalclocktime():
    strng = strftime('%H:%M:%S %p')
    label.config(text=strng)
    label.after(100, digitalclocktime)
 
 
# Style the label widget so that clock will look more attractive
label = Label(ws, font=('Times New Roman', 50, 'bold'),
            background='cyan',
            foreground='white')
 
# Place the clock at the center of the tkinter window
label.pack(anchor='center')
digitalclocktime()
 
mainloop()

Output:

After running the whole code we get the following output in which we can see that the digital clock is created and generated the exact time as a clock. Here we are creating a window and give the title to the window as Pythontpoint and then creating a function called time that is used to display the current time on the label widget.

How to create digital clock using python tkinter
How to create digital clock using Python Tkinter

So, in this tutorial, we have illustrated How to create digital clock using Python Tkinter. Moreover, we have also discussed the whole code used in this tutorial.

Read some more tutorials related to Python Tkinter

Python Tkinter temperature converter

Python Tkinter Todo List

Python Tkinter Simple Calculator

Stone Paper Scissor using Python Tkinter

Python Tkinter Color Game

Python Tkinter Instagram User Detail

146 thoughts on “How to Create Digital Clock Using Python Tkinter”

  1. I truly relished the effort you’ve put in here. The sketch is stylish, your authored material chic, however, you seem to have developed some anxiety about what you intend to deliver subsequently. Assuredly, I will revisit more regularly, akin to I have nearly all the time, in the event you maintain this rise.

    Reply
  2. The breadth of knowledge compiled on this website is astounding. Every article is a well-crafted masterpiece brimming with insights. I’m grateful to have discovered such a rich educational resource. You’ve gained a lifelong fan!

    Reply
  3. I was just as enthralled by your work as you were. Your sketch is elegant, and your written content is sophisticated. However, you seem concerned about potentially delivering something questionable soon. I’m confident you’ll resolve this issue quickly and return to your usual high standards.

    Reply
  4. Your work has captivated me just as much as it has you. The sketch you’ve created is tasteful, and the material you’ve written is impressive. However, you seem anxious about the prospect of presenting something that could be considered questionable. I believe you’ll be able to rectify this situation in a timely manner.

    Reply
  5. I loved as much as you will receive carried out right here The sketch is tasteful your authored subject matter stylish nonetheless you command get got an edginess over that you wish be delivering the following unwell unquestionably come further formerly again as exactly the same nearly very often inside case you shield this hike

    Reply
  6. My admiration for your creations is as substantial as your own sentiment. The visual presentation is tasteful, and the written content is sophisticated. Yet, you seem uneasy about the possibility of presenting something that may cause unease. I’m confident you’ll be able to resolve this issue efficiently.

    Reply
  7. The degree to which I appreciate your creations is equal to your own sentiment. Your sketch is tasteful, and the authored material is stylish. Yet, you seem uneasy about the prospect of embarking on something that may cause unease. I agree that you’ll be able to address this matter efficiently.

    Reply
  8. Fourweekmba You’re so awesome! I don’t believe I have read a single thing like that before. So great to find someone with some original thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the internet, someone with a little originality!

    Reply
  9. I loved as much as youll receive carried out right here The sketch is tasteful your authored material stylish nonetheless you command get bought an nervousness over that you wish be delivering the following unwell unquestionably come more formerly again since exactly the same nearly a lot often inside case you shield this hike

    Reply
  10. What i do not realize is in fact how you are no longer actually much more wellfavored than you might be right now Youre very intelligent You recognize thus considerably in relation to this topic made me in my view believe it from numerous numerous angles Its like men and women are not fascinated until it is one thing to do with Lady gaga Your own stuffs excellent All the time handle it up

    Reply
  11. Активируйте промокод ANDROID777 для 7k Casino и скачайте APK через официальный телеграм канал https://t.me/casino_7kk

    Reply
  12. Keep up the fantastic work! Kalorifer Sobası odun, kömür, pelet gibi yakıtlarla çalışan ve ısıtma işlevi gören bir soba türüdür. Kalorifer Sobası içindeki yakıtın yanmasıyla oluşan ısıyı doğrudan çevresine yayar ve aynı zamanda suyun ısınmasını sağlar.

    Reply
  13. It’s the best time to make a few plans for the
    future and it is time to be happy. I’ve learn this publish and if I may I want to counsel
    you some attention-grabbing issues or advice. Maybe you could write next articles referring to this article.
    I want to read more issues about it!!

    Reply
  14. Hello! Do you know if they make any plugins to help with Search Engine Optimization? I’m trying to
    get my site to rank for some targeted keywords but I’m not seeing very good results.

    If you know of any please share. Thank you! I saw similar article here:
    Warm blankets

    Reply
  15. Sugar defender As someone that’s always bewared regarding my blood sugar, finding Sugar Defender has actually been a
    relief. I really feel so much more in control, and my current examinations have revealed favorable enhancements.
    Understanding I have a dependable supplement to support my
    regular gives me assurance. I’m so thankful for Sugar Protector’s impact on my wellness!

    Reply
  16. Bwer Company is a top supplier of weighbridge truck scales in Iraq, providing a complete range of solutions for accurate vehicle load measurement. Their services cover every aspect of truck scales, from truck scale installation and maintenance to calibration and repair. Bwer Company offers commercial truck scales, industrial truck scales, and axle weighbridge systems, tailored to meet the demands of heavy-duty applications. Bwer Company’s electronic truck scales and digital truck scales incorporate advanced technology, ensuring precise and reliable measurements. Their heavy-duty truck scales are engineered for rugged environments, making them suitable for industries such as logistics, agriculture, and construction. Whether you’re looking for truck scales for sale, rental, or lease, Bwer Company provides flexible options to match your needs, including truck scale parts, accessories, and software for enhanced performance. As trusted truck scale manufacturers, Bwer Company offers certified truck scale calibration services, ensuring compliance with industry standards. Their services include truck scale inspection, certification, and repair services, supporting the long-term reliability of your truck scale systems. With a team of experts, Bwer Company ensures seamless truck scale installation and maintenance, keeping your operations running smoothly. For more information on truck scale prices, installation costs, or to learn about their range of weighbridge truck scales and other products, visit Bwer Company’s website at bwerpipes.com.

    Reply
  17. sugar defender ingredients I’ve fought with blood sugar fluctuations for several years, and
    it truly affected my power degrees throughout the day.
    Given that beginning Sugar Defender, I really feel much more well balanced and
    sharp, and I do not experience those mid-day plunges any longer!

    I enjoy that it’s a natural solution that works without
    any extreme side effects. It’s absolutely been a game-changer for me

    Reply
  18. I’m amazed, I must say. Rarely do I come across a blog that’s both educative and engaging, and let me tell you, you have hit the nail on the head. The issue is something that not enough people are speaking intelligently about. I’m very happy that I stumbled across this during my search for something concerning this.

    Reply
  19. Can I simply just say what a comfort to find an individual who genuinely knows what they are talking about online. You definitely realize how to bring an issue to light and make it important. More people must look at this and understand this side of the story. I was surprised you’re not more popular given that you definitely possess the gift.

    Reply
  20. After I initially commented I appear to have clicked on the -Notify me when new comments are added- checkbox and from now on whenever a comment is added I recieve 4 emails with the exact same comment. There has to be a way you can remove me from that service? Thanks.

    Reply
  21. I have been exploring for a little bit for any high quality articles or blog posts in this kind of house . Exploring in Yahoo I at last stumbled upon this site. Reading this information So i am glad to exhibit that I have a very excellent uncanny feeling I came upon just what I needed. I so much surely will make certain to do not put out of your mind this website and provides it a look a continuing.

    Reply
  22. You are so awesome! I don’t think I’ve truly read through something like that before. So good to find another person with some unique thoughts on this topic. Seriously.. thanks for starting this up. This site is one thing that is needed on the internet, someone with some originality.

    Reply

Leave a Comment