Hi again,
ok, I found it.
Here you have the answer:
class IconView(gtk.Iconview):
def __init__(self):
...
crpb = gtk.CellRendererPixbuf()
self.pack_start(crpb, False)
self.set_cell_data_func(crpb, self.cell_pixbuf_func)
# self.set_text_column(6)
crtxt = gtk.CellRendererText()
crtxt.set_property('width', ITEM_WIDTH-10)
crtxt.set_property('ellipsize', pango.ELLIPSIZE_END)
crtxt.set_property('alignment', pango.ALIGN_CENTER)
crtxt.set_property('scale', 0.8)
self.pack_start(crtxt, False)
self.set_attributes(crtxt, text=6)
...
def cell_pixbuf_func(self, celllayout, cell, model, iter):
pb = get_cover(model.get_value(iter, 1), 'huge') # book file path
cell.set_property('pixbuf', pb)
Sorry for the noise,
Iñigo Serna
2010/11/21 Iñigo Serna <[email protected]>:
> Hi,
>
> I'm trying to set a custom function to render the images on a
> gtk.IconView, instead of the usual "gtk.IconView.set_pixbuf_column()"
> method.
>
> To do it, I'm using "set_cell_data_func" method that gtk.IconView
> inherits from gtk.CellLayout [1] and [2].
>
> It doesn't work, reporting next error.
> """
> iconview.py:19: GtkWarning:
> gtk_icon_view_cell_layout_set_cell_data_func: assertion `info != NULL'
> failed
> self.set_cell_data_func(crpb, self.cell_pixbuf_func)
> """
> See the attached example.
>
> Any idea?
>
> I succesfully use "set_cell_data_func" method with treeviews, so the
> issue comes within gtk.IconView...
>
>
> My purpose is to render the pixbufs according to some "size"
> preference so images are shown smaller or bigger.
> The option of filling the store each time "size" preference is changed
> is not a valid solution as there a lot of rows there so it would be
> very slow.
>
>
> Thanks,
> Iñigo Serna
>
>
> [1] http://www.pygtk.org/docs/pygtk/class-gtkiconview.html
> [2]
> http://www.pygtk.org/docs/pygtk/class-gtkcelllayout.html#method-gtkcelllayout--set-cell-data-func
>
--
Iñigo Serna
Katxijasotzaileak
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/