After some tinkering, I found out that the image is properly displayed when stored in a variable of the GUI, i.e. using self
self.gif1 = PhotoImage(file='1.gif')
self.canvas.create_image(0, 0, image=self.gif1, anchor=NW)
I have no idea why, but This works, while naming the variable just gif1
(or any other name), without self
, does not. Tested both in your code and in a minimum example.
Update: As @Bryan pointed out, the garbage collector disposes the PhotoImage
instance when __init__
finishes. You have to keep a reference to the instance beyond the scope of the constructor, e.g. using self
, or global
. Given the problem at hand, it might be best to create a dict
, storing the images using the names of the cards as keys.