1
ちょっと私のコードでは、Pythonで初心者私はコードを実行するたびに再生されるアニメーションGIFがあります。アドビなどで開いていると、実際にはGIF画像が透明ですが、問題はコードを実行するときです.GIFに含まれる色の灰色のフレームです。色のグレーを削除して、見ることができるだけです私の唯一のアニメーションGIFTkinter背景が透明に表示されない
これは私のコードです:
# mimic an animated GIF displaying a series of GIFs
# an animated GIF was used to create the series of GIFs
# with a common GIF animator utility
import time
from Tkinter import *
root = Tk()
imagelist = ["dog001.gif","dog002.gif","dog003.gif"]
# extract width and height info
photo = PhotoImage(file=imagelist[0])
width = photo.width()
height = photo.height()
canvas = Canvas(width=width, height=height)
canvas.create_line(0,240,640,240, fill='blue')
canvas.pack()
# create a list of image objects
giflist = []
for imagefile in imagelist:
photo = PhotoImage(file=imagefile)
giflist.append(photo)
# loop through the gif image objects for a while
for k in range(0, 10):
for gif in giflist:
canvas.delete(ALL)
canvas.create_image(width/2.0, height/2.0, image=gif)
canvas.update()
time.sleep(0.1)
root.mainloop()[![enter image description here][1]][1]