Weekend Python Project : Python Digital Clock

LUX26 Multi-Color Clocks — Masterclock, Inc.

Digital clock python project is designed using two modules time and tkinter in addition to the user defined function tick().

Time Module : This module provides various time-related functions. For related functionality, see also the datetime and calendar modules. Although this module is always available, not all functions are available on all platforms. Most of the functions defined in this module call platform C library functions with the same name. It may sometimes be helpful to consult the platform documentation, because the semantics of these functions varies among platforms. For complete description follow the link : https://docs.python.org/3/library/time.html

Tkinter Module : The tkinter package (“Tk interface”) is the standard Python interface to the Tk GUI toolkit.

Tkinter is the standard GUI library for Python. Python when combined with Tkinter provides a fast and easy way to create GUI applications. Tkinter provides a powerful object-oriented interface to the Tk GUI toolkit.

Creating a GUI application using Tkinter is an easy task. All you need to do is perform the following steps −

Source Code :

import time
import tkinter as tk
def tick(time1 =''):
    # get the current time from PC 
    time2 = time.strftime('%H:%M:%S')
    if time2!= time1:
        time1 = time2
        clock.config(text =time2)
root= tk.Tk()
clock = tk.Label(root,font =('arial',40,'bold'),bg='green')
clock.pack(fill ='both',expand=1)

Output :

…………………………………… Dr.Thyagaraju G S

Leave a Reply

Your email address will not be published.