How to do a Clock in Python


Code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from Tkinter import*
import time

root = Tk()
root.focus()
root.title("Clock")
root.config(cursor='watch')
time1 = ''
clock = Label(root, font=('ubuntu', 30, 'bold'), bg='#3C3B37', fg='white', bd=0)
clock.pack(fill=BOTH, expand=1)
def tick():
    global time1
    time2 = time.strftime('%H:%M:%S')
    if time2 != time1:
        time1 = time2
        clock.config(text=time2)
    clock.after(200, tick)
tick()
root.mainloop()

Comentarios

Entradas populares de este blog

How to do an Email Bomber with Python

How to make a Christmas animation in HTML

Chat with Firebase