I have a python module that converts python's datetime.datetime.now() function to returns an image according to the number is sees. If it sees 01 seconds it returns two images one of 0 and one of 1. These are just jpg images. My python modules just resturns a dictionary like so:
{'am_pm': '{file_path}am.jpg', 'hour': '{file_path}five.jpg', 'second2': {file_path}one.jpg, 'second1': {file_path}zero.jpg, 'colon': '{file_path}Colon.jpg', 'minute2': '{file_path}zero.jpg', 'minute1': '{file_path}zero.jpg'}
I then have the following code in an attempt to display it in a label. Quite new to using tKinter though.
from PIL import ImageTk, Image
import datetime
from translator import Translator # my converter to get the above dict
import Tkinter as tk
def counter_label(label):
def count():
clock.get_time(datetime.datetime.now())
image = clock.return_images() # this is the dict mentioned above
label.configure(image=ImageTk.PhotoImage(Image.open(image['second2']))) # just using one entry in the dict for now.
label.after(1000, count)
count()
root = tk.Tk()
root.title("Counting Seconds")
label = tk.Label(root, fg="green")
label.pack()
clock = Translator()
counter_label(label)
button = tk.Button(root, text='Stop', width=25, command=root.destroy)
button.pack()
root.mainloop()
The code runs and I can see the label refresh, however I cannot see the jpg image in the label. What am I doing wrong?