代码拉取完成,页面将自动刷新
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()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。