Hello I am doing a job that I need (from a tkinter window containing an image) call another window that contains another imagem.I tried the following:
from tkinter import*
def abrir1():
b =Tk()
imagen = PhotoImage(file= "F2.png")
la = Label(b,image =imagen)
la.pack()
def abrir2():
b =Toplevel()
imagen = PhotoImage(file= "F2.png")
la = Label(b,image =imagen)
la.pack()
a = Tk()
canvas = Canvas(a, bg ="black",width = 512,height =512)
canvas.pack()
imagem = PhotoImage(file = "E2.png")
a1 = canvas.create_image(256,256,image = imagem)
btu1 = Button(a,text ="Abri1!",command = abrir1)
btu1.place(x = 150,y=400)
btu2 = Button(a,text ="Abri2!",command = abrir2)
btu2.place(x = 300,y=400)
But when I press the first button ( btu1 ) it returns the following error message:
_tkinter.TclError: image "pyimage2" doesn't exist
And when when I press the second button ( btu2 ) does not happen error but does not show the image, only the new window is created ;
I've tried several ways including placing * with canvas and without canvas* ;