Python Forum
[Tkinter] Image does not show in treeview.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Image does not show in treeview.
#1
I'm trying to put images into treeviews.

Why does the image file Part.png not show up in this treeview.

I've loaded the same image ( Part.png) to show in the window and that works OK. are there some prerequisites for images on treeviews?



    tupbomi = [tuple(row) for row in all_rows]

    # How may items in this BOM
    print(len(tupbomi))
    numbomi = (len(tupbomi))

    for nbi in range(0,(numbomi)):
        tupbomd=tupbomi[nbi]
        print(( str(nbi)) + ' ' + tupbomd[1] + ' ' + tupbomd[2] + ' ' + tupbomd[3])

        img = tk.PhotoImage(file='resources/Part.png')
                # Check that image and path are correct by displaying on window
        window.tk.call('wm', 'iconphoto', window._w, PhotoImage(file='resources/Part.png'))
                # OK image shows

        # This will be BOM
        if tupbomd[2]== 'D':
            nbi= tree1.insert("", nbi, str(nbi), text=tupbomd[3], image=img , values=(tupbomd[2], tupbomd[3], tupbomd[4]))
            tree1.insert(nbi, "end", str(nbi)+'.1', text=tupbomd[3], image=img , values=(tupbomd[2], tupbomd[3], tupbomd[4]))

        # This will be a part
        else:
            tree1.insert("", nbi, text=tupbomd[3], image=img, values=( tupbomd[2], tupbomd[3], tupbomd[4]))
Reply


Messages In This Thread
Image does not show in treeview. - by KevinBrown - May-05-2019, 08:22 PM
RE: Image does not show in treeview. - by micseydel - May-05-2019, 08:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Load image and show in label ko_fal 8 3,035 Oct-25-2022, 09:20 AM
Last Post: ko_fal
  [Tkinter] [split] Is there a way to embed a treeview as a row inside another treeview? CyKlop 5 3,346 Oct-20-2021, 12:14 AM
Last Post: CyKlop

Forum Jump:

User Panel Messages

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