How to make a clock in Python

This little script shows the time in a window.

'''Import libraries'''
from Tkinter import *
import time

'''Define a function'''
def tick():
    '''Assign current time to time_string'''
    time_string = time.strftime("%H:%M:%S")

    '''Update the clock labels text'''
    clock.config(text=time_string)

    '''After 200ms run tick'''
    clock.after(200, tick)

'''Make the window'''
window = Tk()

'''Make the Label clock, put in on window and give it som attributes'''
clock = Label(window, font=("serif", 50, "bold"), bg="white")

'''Place the clock label'''
clock.grid(row=0, column=1)

'''Run the tick function'''
tick()

'''Setting the window title'''
window.title("Clock")

'''Place the window inthe top left corner'''
window.geometry("+0+0")

'''Prevent users to resize the window'''
window.resizable(False, False)

'''Run main loop'''
window.mainloop()

Clock

blogroll

social