Answer the question
In order to leave comments, you need to log in
How to insert a gif into a tkinter window?
I want to insert a gif into the tkinter window, and everything seems to be correct, but the console says that it does not find the file
Code:
import tkinter
ssw = tkinter.Tk()
def six():
toplvl = tkinter.Toplevel() #created Toplevel widger
photo = tkinter.PhotoImage(file = 'tenor.gif')
lbl = tkinter.Label(toplvl ,image = photo)
lbl.image = photo #keeping a reference in this line
lbl.grid(row=0, column=0)
def base():
la = tkinter.Button(ssw,text = 'yes',command=six)
la.grid(row=0, column=0) #specifying row and column values is much better
base()
ssw.mainloop()
Answer the question
In order to leave comments, you need to log in
Perhaps you did not put this project in the file with this gif and Python simply cannot find this gif, so it displays an error!
Example:
You make a project and a GIF in one file.
And you make code like this:
from tkinter import *
tk = Tk()
canvas = Canvas(tk, width=1000, height=800)
image = PhotoImage(file=r'D:\\файл\\файл\\гифка')
canvas.create_image(размер, размер, image=my_background, anchor='nw')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question