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.
#4
While the following code is inside the function it will at least provide an image for the last item on the list. If the code is outside the function it provides the same image for all items in the treeview.

At runtime I want to do is read the required image for example tupbomd[n] and apply the appropriately rendered image to that particular line of the treeview.



 

        widt = 16
        hght = 16
        img = Image.open('resources/Part.png')
        img = img.resize((widt, hght), Image.ANTIALIAS)
        render = ImageTk.PhotoImage(img)
    for nbi in range(0,(numbomi)):

        tupbomd=tupbomi[nbi]

        widt = 16
        hght = 16
        img = Image.open('resources/Part.png')
        img = img.resize((widt, hght), Image.ANTIALIAS)
        render = ImageTk.PhotoImage(img)

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

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


    conn.close()
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
RE: Image does not show in treeview. - by KevinBrown - May-05-2019, 11:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Load image and show in label ko_fal 8 2,919 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,303 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