Cant add image to Tkinter Listbox
Question: I'm trying to add an image to a Listbox, but instead of the image I see an
entry called "pyimage1" in the Listbox. I've successfully displayed images
using the Text and Label widgets, but I can't figure out the Listbox widget.

I checked the documentation but it doesn't indicate how to properly update a
Listbox with an image.

What is the best method to add an image as a Listbox entry?

Here is what I've tried so far:

    
    
    #!/usr/bin/python
    # test: lb_and_jpg.py
    
    from Tkinter import *
    from PIL import Image, ImageTk
    
    import os
    
    my_image_file = os.getcwd() + r'\logo.jpg'
    
    class MainApp:
        def __init__(self, parent):
            self.myParent = parent
            self.main_container = Frame(parent)
            self.main_container.grid(row=0, rowspan=10, column=0, columnspan=20)
    
            # Defining frames
            self.left_frame = Frame(self.main_container)
            self.left_frame.grid(row=0, rowspan=10, column=0, columnspan=5)
    
            self.right_frame = Frame(self.main_container)
            self.right_frame.grid(row=0, rowspan=10, column=6, columnspan=14)
    
            self.left_listbox = Listbox(self.left_frame, height=10, width=5)
            self.left_listbox.grid(row=0, column=0)
    
            self.right_listbox = Listbox(self.right_frame, height=10, width=14)
            self.right_listbox.grid(row=0, column=0)
    
            my_img = Image.open(my_image_file)
            my_image = ImageTk.PhotoImage(my_img)
    
            self.right_listbox.insert(END, my_image)
    
    
    root = Tk()
    root.title("ListBox and JPG")
    mainapp = MainApp(root)
    root.mainloop()
    


Answer: You cannot add images to the listbox. You will need to use another widget,
such as the ttk.Treeview widget.

