Tkinter displaying distorted image

亡梦爱人 提交于 2019-12-24 05:20:44

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!