I am trying to create a fullscreen clock in python that will display fullscreen using tkinter.
so far, I have 2 bits of code which work, to create a fullscreen tkinter window, and to print the time using strftime.
Trying to merge the 2 bits of code together is doing my head in - I can either get a clock running in the shell, or a tkinter window that displays time but does not update.
I need to display the time in a tkinter window AND have the time update every 0.5 seconds.
What I have is below - it is far from finished. Any help greatly appreciated. Jon
import sys
if sys.version_info[0] == 2:
from Tkinter import *
import Tkinter as tk
else:
from tkinter import *
import tkinter as tk
import time
from time import *
import os
from os import *
clock = tk.Tk() # make it cover the entire screen
w, h = clock.winfo_screenwidth(), clock.winfo_screenheight()
clock.overrideredirect(1)
clock.geometry("%dx%d+0+0" % (w, h))
clock.focus_set() # <-- move focus to this widget
clock.bind("<Escape>", lambda e: e.widget.quit())
###############this is the problem...
while True:
time = strftime("%A, %d %B %Y %X")
sleep (0.5)
#print (time)
###############this is the problem...
text = Text(clock)
text.insert(INSERT, time)
text.pack()
clock.mainloop()