【发布时间】:2021-08-14 16:05:28
【问题描述】:
我在 After Effects 中制作了一个加载轮动画,我正在尝试在 python 中将它与 tkinter 一起使用。尽管动画是每秒 60 帧,但它会动摇并且不会显示整个帧。这是我的代码:
from tkinter import *
from PIL import Image
root = Tk()
root.geometry("1920x1080")
image1 = Image.open("LoadingWheel.gif")
framesTotal = image1.n_frames
animation = [PhotoImage(file="LoadingWheel.gif", format=f'gif -index {i}') for i in range(framesTotal)]
def update(ind):
frame = animation[ind]
label.configure(image=frame)
ind += 1
if ind == framesTotal:
ind = 0
root.after(60, update, ind)
label = Label(root)
label.pack()
root.after(0, update, 0)
root.mainloop()
第一张图是我运行脚本时的截图,第二张图是它的样子!
我希望有人知道如何解决这个问题!
提前致谢!
【问题讨论】:
标签: python animation tkinter gif