I am trying to make a window (with Tkinter) with a label that dynamically updates the time every minute.
Here is my code:
Code: Select all
import Tkinter as tk
import time
def update_time():
time_string = time.strftime('%I:%M %p')
self.message.config = "The current time is " + time_string)
root.after(60000, update_time)
root = tk.Tk()
root.attributes('-fullscreen', True)
message = tk.Label(root,
text="The current time is " + time_string,
font = "Helvetica 30").pack()
update_time()
root.mainloop()
When I try to run it by itself, the Python crash handler says that there is no module named Tkinter.
I am using Python 2.
When I run the code below, it works fine, but doesn't update the time:
Code: Select all
import Tkinter as tk
import time
def update_time():
time_string = time.strftime('%I:%M %p')
#self.message.config = "The current time is " + time_string)
root.after(60000, update_time)
root = tk.Tk()
root.attributes('-fullscreen', True)
message = tk.Label(root,
text="The current time is " + time_string,
font = "Helvetica 30").pack()
update_time()
root.mainloop()
Could anyone tell me what I'm doing wrong?