simple animation using tkinter

I have a simple code to visualise some data using tkinter. A button click is bound to the function that redraws the next “frame” of data. However, I’d like to have the option to redraw automatically with a certain frequency. I’m very green when it comes to GUI programming (I don’t have to do a lot for this code), so most of my tkinter knowledge comes from following and modifying examples. I guess I can use root.after to achieve this, but I’m not quite sure I understand how from other codes. The basic structure of my program is as follows:

Tkinter grid_forget is clearing the frame

from tkinter import * from PIL import ImageTk,Image root=Tk() root.title("Image Viewer") def buttonforward(image_number): global myLabel myLabel.grid_forget() myLabel = Label(image=imagelist[image_number-1]) myLabel.grid(row=0, column=0, columnspan=3) return my_img1 = ImageTk.PhotoImage(Image.open('mountain1.jpg')) my_img2 = ImageTk.PhotoImage(Image.open('mountain2.jpg')) my_img3 = ImageTk.PhotoImage(Image.open('mountain3.jpg')) my_img4 = ImageTk.PhotoImage(Image.open('mountain4.jpg')) my_img5 = ImageTk.PhotoImage(Image.open('mountain5.jpg')) myLabel = Label(image=my_img1, ).grid(row=0, column=0, columnspan=3) imagelist = [my_img1, my_img2, my_img3, my_img4, my_img5] button_back = Button(root, text='<<').grid(row=1,column=0) … Read more