tkinter image appearing partially white instead of correct colour

62 views Asked by At

Recently i have been trying to get gifs to work with tkinter and after some research i figured out how i was going to do it and wrote a class to make playing them easier

class GifWrapper():
    def __init__(self, parent, file=None):
        self.file=file
        self.parent=parent
        if file:
            self.info=parse(file=file)
        else:
            raise GifError("expected file to be passed")
        print(str(self.info.frames)+" "+str(len(self.info.delays)))
        self.frames=[]
        for i in range(0, self.info.frames):
            self.frames.append(PhotoImage(file=self.file, format="gif -index {}".format(i)))
            print("added frame {}".format(i))
    async def play(self):
        curFrame=0
        for i in self.info.delays:
            await asyncio.sleep(i/100)
            self.parent["image"]=self.frames[curFrame]
            curFrame+=1

However when i tested this out i noticed that my gif was pretty strange as seen here, the first frame seems to be only slightly affected, the second frame seems perfectly ok and the rest are pretty badly affected by the issue, i remember reading somewhere that pixels with an alpha of 0 were treated as transparent in PhotoImage files so i assume that this might be the problem however i think it's weird that the first and second images are affected differently, is there a way to change this?

0

There are 0 answers