Only the code you showed works perfectly. Certainly, there is much more code from your program that you have not shown.
Most of the time, this error occurs when you create one or more windows with the Tk
or when you destroy the current one, create a new one and reuse the previous Photoimage. Example:
This code generates the same error you showed because 2 windows are created:
from tkinter import *
def entrar():
#Janela Principal
janela = Tk()
janela.title("Salvadados")
janela.geometry('400x600')
#fotofundo
back = Label(janela)
back.la = PhotoImage(file = 'image.png')
back['image'] = back.la
back.place(x=0,y=0)
root = Tk()
entrar()
This code causes error because I try to reuse the previous Photoimage:
from tkinter import *
def entrar():
#Janela Principal
janela = Tk()
janela.title("Salvadados")
janela.geometry('400x600')
#fotofundo
back = Label(janela)
back.la = PhotoImage(file = 'C:/Users/Jean Extreme/Desktop/Jean Extreme/Extreme/Fotos/Placa Minecraft Like.png')
back['image'] = back.la
back.place(x=0,y=0)
return janela,back
root , back = entrar()
root.destroy()
new_root = Tk()
label = Label(new_root)
label["image"] = back.la
label.pack()
This code does not generate error:
from tkinter import *
def entrar():
#Janela Principal
janela = Tk()
janela.title("Salvadados")
janela.geometry('400x600')
#fotofundo
back = Label(janela)
back.la = PhotoImage(file = 'image.png')
back['image'] = back.la
back.place(x=0,y=0)
entrar()
To fix the problem you should not create more than one window with Tkinter and whenever you destroy one window to create another, also create a new one PhotoImage
.