The update function
# dynamically update image def update_image(): global photo # new image imgPath = "/Users/Shared/Images/image1.png" doesImageExist=os.path.isfile(imgPath) if doesImageExist == False: # default image imgPath = "/Users/Shared/Images/default/image1.png" photo = ImageTk.PhotoImage(Image.open(imgPath)) photoBox.config(image=photo)
Part of my widget or form
root = tk.Tk() root.geometry("350x300")# X Y root.resizable(0,0) root.title("Window Title") root.attributes('-topmost', True) imgPath = "/Users/Shared/Images/image1.png" photo = ImageTk.PhotoImage(Image.open(imgPath)) photoBox = tk.Label(root, image = photo) photoBox.pack() root.mainloop()
Call the image update
root.after(1000, update_image)