May-05-2019, 11:47 PM
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.
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()