[wxPython] Implementing a list of thumbnails with wxListCtrl?

Hi all,

I'm working on KeyPhoto, my little program to organize a collection of digital photos:
http://sourceforge.net/projects/keyphoto

The main window has 4 parts: a filesystem tree, a panel with thumbnails of the photos in the selected directory, a panel with informations on the selected photo, and a panel to assign keywords to the selected photo (and create new keywords, search photos etc..).

Right now the thumbnail panel is implemented as a wxScrolledWindow in which I put the thumbnails by hand (computing coordinates etc.). What I'd like to do is use a wxListCtrl to display my thumbnails and thus allowing the user to select several images... and saving me the manual layout of images!

I tried like this (see the PhotoSelector class below), but even when all thumbnails have the same size, they are not displayed. When they have different size, an error message "Couldn't add an image to the image list."
So, am I asking too much from wxListCtrl? Has anyone contributed a widget to list images? Basically what I'd like for this thumbnail panel is what ACDSee has.

Otherwise I'm quite happy with wxPython :slight_smile:

thanks for your time,

so, here is the code:

class PhotoSelector(wxListCtrl): # test using a ListCtrl... not working yet
    
    """Displays a list of photos for selection.
    Implements the FileSelector interface (TBD)"""

    def __init__(self, parent, id, listener, photo_coll):
        """listener.on_file_sel_changed will be called
        when a photo is clicked.
        The Photos to display must be in photo_coll.
        """
        wxListCtrl.__init__(self, parent, id)
        self.listener = listener
        self.photo_coll = photo_coll
        EVT_LIST_ITEM_SELECTED(self, id, self.on_image_click)

    def set_files(self, photos):
        """Clears itself and displays the given photos."""
        self.DeleteAllItems()
        self.photos = photos
        image_list = wxImageList(150, 112)
        for photo in photos:
            image_list.Add(self.photo_coll.get_thumbnail(photo).ConvertToBitmap())
        self.SetImageList(image_list, wxIMAGE_LIST_NORMAL)
        i = 0
        for photo in photos:
            self.InsertStringItem(i, photo.name)
            self.SetItemImage(i, i, i)
            i = i + 1

    def on_image_click(self, event):
        photo = self.photos[event.GetIndex()]
        self.listener.on_file_sel_changed(photo)