Fisrt you need to import Tkinter module
Tkinter is the standard GUI library for Python. Tkinter gets its name from Tk interface. When python is combined with Tkinter it provides a fast and easy way to create GUI applications. Tkinter provides a powerful object-oriented interface to the Tk GUI toolkit. Tkinter is a Python binding to the Tk GUI toolkit.
you need Time Module
Time module provides a variety of ways of getting time, In this article, we are going to use strftime() to parse the current time into the Hour: Minutes: Seconds format.
CODE HERE:
import sys
from tkinter import *
import time
def timing():
current_time = time.strftime("%H : %M : %S")
clock.config(text=current_time)
clock.after(200,timing)
root=Tk()
root.geometry("600x300")
clock=Label(root,font=("times",60,"bold"),bg="blue")
clock.grid(row=2,column=2,pady=25,padx=100)
timing()
digital=Label(root,text="AskPython's Digital Clock",font="times 24 bold")
digital.grid(row=0,column=2)
nota=Label(root,text="hours minutes seconds",font="times 15 bold")
nota.grid(row=3,column=2)
root.mainloop()
Comments
Post a Comment