1 Star 0 Fork 0

亓斌/perspective_pi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
wave_man.py 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
qibin01 提交于 2021-03-10 20:25 . convert frame to RGB
from tkinter import *
import time
import threading
from PIL import ImageTk, Image, ImageSequence
from base_canvas import BaseCanvas
class WaveMan(BaseCanvas):
def __init__(self):
super(WaveMan, self).__init__("wave_man")
self.image_name = "./assets/wave_man/wave_man.gif"
self.origin_image_width = 600
self.origin_image_height = 944
self.image_height = self.height
self.image_width = int(self.height / self.origin_image_height * self.origin_image_width)
self.image_view = self.canvas.create_image((self.width / 2, self.image_height / 2), anchor=CENTER)
def __build_frames(self):
self.frames = []
im = Image.open(self.image_name)
for frame in ImageSequence.Iterator(im):
self.frames.append(ImageTk.PhotoImage(frame.convert('RGB').resize((self.image_width, self.image_height))))
def __run(self):
self.__build_frames()
while True:
for frame in self.frames:
self.canvas.itemconfig(self.image_view, image=frame)
self.root.update()
time.sleep(0.05)
def start(self):
threading.Thread(target=self.__run).start()
if __name__ == '__main__':
wave = WaveMan()
wave.start()
wave.root.mainloop()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/qibin/perspective_pi.git
git@gitee.com:qibin/perspective_pi.git
qibin
perspective_pi
perspective_pi
master

搜索帮助