Reputation: 195
I am not sure how to show images from different destinations in Python. I need to know how to make the image show up on my program. I tried using the following code but it would not show the gif file onto the Python program. My file is named "giftest.gif" and it is on the same folder as the program is but it still won't show up, and instead an error pops up.
from tkinter import *
root = Tk()
canvas = Canvas(root, width=500, height=500)
canvas.pack()
imagetest = Image("giftest.gif")
canvas.create_image(250, 250, image=imagetest)
root.mainloop()
Upvotes: 0
Views: 300
Reputation: 7303
You need to use PhotoImage
not Image
.
from tkinter import *
root = Tk()
canvas = Canvas(root, width=500, height=500)
canvas.pack()
imagetest = PhotoImage(file="file.gif")
canvas.create_image(250, 250, image=imagetest)
root.mainloop()
Upvotes: 5