python tkinter 使用 PIL 显示动画 GIF
有没有办法使用 Python 图像库在 Tkinter 中显示动画 GIF?
我认为 ImageSequence 模块 是这样做的方法,但是我不知道如何使用它以及是否可能。
第一个问题是有没有简单的方法。例如:使用 PIL 和 ImageSequence 加载 GIF,然后使用 ImageTk.PhotoImage 将其绘制在 Tkinter 窗口上,它将被动画化。
或者我是否必须自己设置一个函数,使用 after
方法或类似 time.sleep
的方法来循环 GIF 帧并将它们绘制在 tkinter 窗口上?
第二个问题:即使我必须创建一个函数来循环 GIF 帧,ImageSequence 模块是否应该执行此操作,或者 PIL 有另一个模块可以执行此操作?
Is there any way to display an animated GIF in Tkinter using Python Image Library?
I thought the ImageSequence module would be the way to do it, but I don't know how to use it and if it's possible.
The first question is if there is any easy way. For example: load a GIF using PIL and the ImageSequence and just draw it on a Tkinter window using ImageTk.PhotoImage
and it will be animated.
Or do I have to set up a function myself, using the after
method or something like time.sleep
to loop through the GIF frames and draw them on a tkinter window?
The second question: even if I have to make a function to loop through the GIF frames, is the ImageSequence module supposed to do this or PIL has another module for it?
I'm using Python 3.1 and a private port of PIL, indicated in this topic.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它们仍然随 1.1.5(和 1.1.6)一起提供,并且应该可以工作。
如果您缺少的只是脚本目录中的一些文件,您可以获取
它们在这里:
http://svn.effbot.org/public/pil/Scripts/
player.py 从命令行运行,
看看这个是否适合您:
they're still shipped with 1.1.5 (and 1.1.6), and they should work.
if all you're missing is a few files from the script directory, you can get
them here:
http://svn.effbot.org/public/pil/Scripts/
player.py is run from the command line
see if this one works for you:
简单的PIL版本:
Simple PIL version: