
- Python 3 Basic Tutorial
- Python 3 - Home
- What is New in Python 3
- Python 3 - Overview
- Python 3 - Environment Setup
- Python 3 - Basic Syntax
- Python 3 - Variable Types
- Python 3 - Basic Operators
- Python 3 - Decision Making
- Python 3 - Loops
- Python 3 - Numbers
- Python 3 - Strings
- Python 3 - Lists
- Python 3 - Tuples
- Python 3 - Dictionary
- Python 3 - Date & Time
- Python 3 - Functions
- Python 3 - Modules
- Python 3 - Files I/O
- Python 3 - Exceptions
Python to create a digital clock using Tkinter
Python Tkinter can be used to create all kinds of GUI programs for the web and desktop. In this article we will see how to create a digital clock displaying hour, minute and seconds live.
We use the time module to import the method strftime which displays the time in Hour, minute and seconds format. We create a canvas to hold these values. We refresh the values of strftime after every 200 milli seconds. We define a recursive function to achieve this.
Example
import time from tkinter import * canvas = Tk() canvas.title("Digital Clock") canvas.geometry("350x200") canvas.resizable(1,1) label = Label(canvas, font=("Courier", 30, 'bold'), bg="blue", fg="white", bd =30) label.grid(row =0, column=1) def digitalclock(): text_input = time.strftime("%H:%M:%S") label.config(text=text_input) label.after(200, digitalclock) digitalclock() canvas.mainloop()
Output
Running the above code gives us the following result −
- Related Articles
- How to create digital clock with textview in android?
- Design a Digital Clock in Neumorphism Style using JavaScript
- How to create a borderless fullscreen application using Python-3 Tkinter?
- How to create a timer using tkinter?
- C program to print digital clock with current time
- How to create an impressive GUI in Python using Tkinter?
- How to create a Splash Screen using Tkinter?
- How to create a simple screen using Tkinter?
- How to create a directly-executable cross-platform GUI app using Python(Tkinter)?
- How to create a password entry field using Tkinter?
- How to Create an Analog Clock using HTML, CSS, and JavaScript?
- How to create transparent widgets using Tkinter?
- How to create Tkinter buttons in a Python for loop?
- Java Program to create LocalDateTime from Clock
- How do I create a popup window using Tkinter?

Advertisements