rss logo

Graphical Clock Application with Python

Python logo

I work on a openbox window manager environment and I wanted to have a window which show me current time (in order to avoid extra hours) on my screen. So I developed a small python program to get it.


  • OS : Arch Linux
  • python : 3.7.2
  • tk : 8.6.9-2


  • We need to install tk windowing toolkit :
root@host:~# pacman -S extra/tk


#! /usr/bin/python # Role : Graphical Window to show current time # Author : # 1.0 first version #links that helped me : # - # - # - # - #from tkinter import * from tkinter import ttk import datetime import tkinter as tk class WhatTime(tk.Tk): def __init__(self,parent): tk.Tk.__init__(self,parent) self.parent = parent self.initialize() def initialize(self): try: self.grid() self.resizable(False,False) #I don't want that the window can be resized self.hour = tk.StringVar() #Set hour variable self.wm_attributes("-topmost", 1) #Put window on top of others self.PrintTime() label = tk.Label(self,textvariable=self.hour,anchor="w",fg="green",bg="black") #set graphical theme label.config(font=("Courier", 20, "bold")) #set font label.grid(column=0,row=0,columnspan=1,sticky='EW') except ValueError: pass def PrintTime(self): try: value ='%Y-%m-%d %H:%M:%S') #set the time output self.hour.set(value) self.after(1000, self.PrintTime) #will be refreshed each second except ValueError: pass if __name__ == "__main__": app = WhatTime(None) app.title('WT2I?') app.mainloop()


clock image of the python GUI program
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Contact :

contact mail address