1

I want to open a gif file, but only a white square appears. I am using a mac. Here is my code:

def pic(aken, heigth, width, gif):
    name = Canvas(aken, width, height)
    name.create_image(height/2, width/2, image = gif)
    name.place(x=340, y=0)
def aken():
    aken = Tk()
    aken.geometry("800x600")
    sign = PhotoImage(file='CocaCola.gif')
    pic(aken, 120, 120, sign)
aken()
Canvas
  • 5,779
  • 9
  • 55
  • 98

1 Answers1

2

This should be marked as a duplicate. The problem is that the image is being garbage collected, see this Putting gif image in a canvas with Tkinter or look at the original advice here http://effbot.org/pyfaq/why-do-my-tkinter-images-not-appear.htm

Community
  • 1
  • 1
Steve
  • 976
  • 5
  • 15