DEV Community


Posted on


Create a Clock using Python

You can create a simple Clock using Python and in this post we use tkinter to create the GUI for our clock. Firstly download the fonts from the link here and install it in your system if you want to have the same font like in this post.

Now that you've installed the fonts, copy the following code and save it in your system. Try to run the code and your Clock will be displayed.

from tkinter import * 
from tkinter.ttk import *

from time import strftime 

root = Tk()

def time():
    string = strftime("%H:%M:%S %p")
    label.after(1000, time)

label = Label(root, font=("ds-digital", 50), background="black", foreground="cyan")

Enter fullscreen mode Exit fullscreen mode

The clock is shown below:
Image description

Top comments (0)

Here is a post you might want to check out:

Regex for lazy developers

regex for lazy devs

Sorry for the callout 😆