Python Forum
Tkinter: An image and label are not appearing.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tkinter: An image and label are not appearing.
#2
You need to keep a reference to the image. I would do it like this:
        image3 = ImageTk.PhotoImage(resimage_download)
        image_download = tk.Label(window, image=image3, borderwidth=0)
        image_download.place(x=62, y=240)

        image_download.image = image3
When you use an image in a label, tkinter does not keep a reference to the image object. image3 was the only reference to the image. When the read_column function returned, all local variables from that function cease to exist. There is no longer an image3 variable, so there is nothing that references the variable. Python assumes you no longer need the image, not a bad assumption as there is no way you can do anything with the image, so it deletes the image garbage collects the image memory.

Adding a variable to the label that references the image prevents this from happening.
Reply


Messages In This Thread
RE: Tkinter: An image and label are not appearing. - by deanhystad - Mar-06-2024, 08:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter destroy label inside labelFrame Nick_tkinter 3 4,675 Sep-17-2023, 03:38 PM
Last Post: munirashraf9821
  My Background Image Is Not Appearing (Python Tkinter) HailyMary 2 4,702 Mar-14-2023, 06:13 PM
Last Post: deanhystad
  [Tkinter] Load image and show in label ko_fal 8 3,221 Oct-25-2022, 09:20 AM
Last Post: ko_fal
  [Tkinter] Updating Tkinter label using multiprocessing Agusms 6 3,322 Aug-15-2022, 07:10 PM
Last Post: menator01
  simple tkinter question function call not opening image gr3yali3n 5 3,601 Aug-02-2022, 09:13 PM
Last Post: woooee
  [Tkinter] Tkinter don't change the image DQT 2 1,709 Jul-22-2022, 10:26 AM
Last Post: menator01
  [Tkinter] The Text in the Label widget Tkinter cuts off the Long text in the view malmustafa 4 5,256 Jun-26-2022, 06:26 PM
Last Post: menator01
  How to redraw an existing image to a different image TkInter zazas321 6 6,066 Jul-08-2021, 07:44 PM
Last Post: deanhystad
  [Tkinter] image in label not showing? rwahdan 2 8,460 Jun-25-2021, 10:27 AM
Last Post: rwahdan
  tkinter showing image in button rwahdan 3 5,742 Jun-16-2021, 06:08 AM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020