问题
I am trying to display a gif using Tkinter, but when the gif loads it looks very odd. I have pasted screenshots of the original gif and the gif displayed in Tkinter. This does not happen with only one gif, but every gif I use.
Original Frame in Gif:
Frame seen in tkinter:
Here is the code:
from Tkinter import *
import time as t
root = Tk()
frames = []
i = 0
while True:
try:
frames.append(PhotoImage(file='display.gif',format='gif -index %i' %(i)))
i += 1
except TclError:
break
def update(ind):
if ind >= len(frames):
ind = 0
frame = frames[ind]
ind += 1
label.configure(image=frame)
root.after(100, update, ind)
label = Label(root)
label.pack()
root.after(0,update,0)
root.mainloop()
来源:https://stackoverflow.com/questions/55013938/tkinter-displaying-distorted-image