python tkinter display time in a windows -
i starting gui in python tkinter.and want display current time hh:mm:ss in center of windows(with big digit if possible).this app code: basic full screen windows background picture.
import tkinter tk tkinter import tk, frame, both import tkinter pil import image, imagetk root = tk.tk() root.attributes('-fullscreen', 1) im = image.open('spring.png') tkimage = imagetk.photoimage(im) myvar=tkinter.label(root,image = tkimage) myvar.place(x=0, y=0, relwidth=1, relheight=1) root.mainloop()
edit: by current time mean keep updating time clock
add compound
parameter myvar
object value tkinter.center
, text
parameter time string. create time string add
import time time_string = time.strftime('%h:%m:%s')
now myvar
like
myvar=tkinter.label(root,image = tkimage, text = time_string, compound = tkinter.center)
for further reference see: python time: https://docs.python.org/2/library/time.html#time.strftime
python tkinter label : http://effbot.org/tkinterbook/label.htm
Comments
Post a Comment