Let's say I have this Panel:
panel = ttk.Label(window,image = image1)
I want to know what image he is storing inside of him. Is there any way to get this?
Let's say I have this Panel:
panel = ttk.Label(window,image = image1)
I want to know what image he is storing inside of him. Is there any way to get this?
The simplest solution is to attach the image object to the label widget.
panel = ttk.Label(window, image=image1)
panel.image = image1
This solves two problems. For one, it preserves the reference to the image so that it doesn't get destroyed by python's garbage collector. For another, you can then reference the image object itself as long as you have a reference to the image. If you have a reference to the image, you can get the filename with the cget
method:
print(f"filename: {panel.image.cget('file')}")