Whilst I didn't see the animation get slower, it did use a lot of memory. I found loading the frames first and then animating the image resulted in much lower memory usage, as you are not opening and processing an image every millisecond.
Here is the amended code:
label = Label(screen, image = "")
label.pack()
num = 0
img = None
frames = [PhotoImage(file = "gif.gif", format = "gif -index {}".format(num)) for num in range(180)]
def animate():
global num
global img
label.configure(image = frames[num])
num = (num+1)%180
screen.after(100, animate)
animate()
screen.mainloop()
I would not recommend setting screen.after
to 1 millisecond as this makes the gif too fast. I found 100ms was fast enough.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…