[pygtk] comboboxes and images

Tim Evans t.evans at aranz.com
Mon Aug 23 07:00:02 WST 2010


On 2010-08-23 8:09, Greg Bair wrote:
> Hey everyone,
>
> When trying to insert an image into a combobox, I couldn't find a good
> way online. So, I dug around the docs, and came up with this solution.
>
> self.lst_services = gtk.ListStore(str, gtk.gdk.Pixbuf)
>
> for service in services :
>     imagefile = '../../data/' + service + '.png'
>     image = gtk.Image()
>     image.set_from_file(imagefile)
>     pixbuf = image.get_pixbuf()

The better way to load a pixbuf from a file is:

     pixbuf = gtk.gdk.pixbuf_new_from_file(imagefile)

-- 
Tim Evans


More information about the pygtk mailing list