1

I am currently working on a project to play videos in Tkinter. I have set the code to run through a loop and play each frame (so it would be a bit like a gif) but the code doesn't seem to play the loop, it just displays the first image. What am I doing wrong? Here is the code:

from tkinter import*

root=Tk()
root.geometry=('400x400')
loop=1
while loop>0:
    if loop<240:
        filepath="Frames\Frame_Layer_"+str(loop)+".png"
        imageback=PhotoImage(file=filepath)
        button1=Button(root, image=imageback).pack()
        loop=loop+1
    else:
        loop=1
    root.mainloop()

When I run the code it comes up with a message saying too early to create image???

Any help would be much appreciated. Thanks in advance,

Mitra0000

Mitra0000
  • 172
  • 1
  • 1
  • 10
  • Are you absolutely certain that exact code gives you that error? That error usually crops up if you create the image before you create the root. Also, are you really calling `mainloop` inside the `while` loop? – Bryan Oakley Oct 07 '15 at 21:45
  • 1
    The title says you want to play videos, but the code has nothing to do with a video. Instead, the code just cycles through images which is essentially a duplicate of http://stackoverflow.com/q/11502879/7432. – Bryan Oakley Oct 07 '15 at 21:48

0 Answers0