0
我使用的Tkinter從以下網頁動畫使用指導GIF: Tkinter animation will not work的Tkinter未能動畫GIF
但是我不能得到的建議工作。現在,我有這樣的事情
import tkinter as tk
root = tk.Tk()
frames = [tk.PhotoImage(file = '/home/quantik/Pictures/dice.gif',format="gif -index %i" %(i)) for i in range(5)]
def animate(n):
if (n < len(frames)):
label.configure(image=frames[n])
n+=1
root.after(300, animate(n))
label = tk.Label(root)
label.pack()
root.after(0, animate(0))
root.mainloop()
但是它只是顯示最後一個圖像中frames
我試過幾種方法,但我不斷收到相同的結果。有沒有人有任何建議,爲什麼這可能會發生?
This Works!我想我沒有完全理解'after'文檔,我認爲它會等待300毫秒,然後調用'animate(args)'。謝謝! – quantik