[pygtk] problem with IconView

remi.sassolas at gmail.com remi.sassolas at gmail.com
Wed Apr 19 15:49:28 WST 2006


Hi,
I have a little problem with IconViews, as far as the text under the picture
(the pixbuf) of the icons is concerned (let's call it a 'label').
Indeed the words of this text are truncated to comply with the "item-width"
property, which I don't find very nice.
Here is a small example of an IconView, so that you can see what I meant by
'truncated'.

# file example.py
import gtk
window=gtk.Window()

iconview = gtk.IconView()

model = gtk.ListStore(str, gtk.gdk.Pixbuf)
iconview.set_model(model)
iconview.set_text_column(0)
iconview.set_pixbuf_column(1)

pixbuf1 = iconview.render_icon(gtk.STOCK_APPLY,gtk.ICON_SIZE_BUTTON)
model.append(['Apply', pixbuf1])

pixbuf2 = iconview.render_icon(gtk.STOCK_CANCEL,gtk.ICON_SIZE_BUTTON)
model.append(['Cancel', pixbuf2])

window.add(iconview)
window.show_all()

iconview.select_path((1,))
print iconview.get_children()
gtk.main()
# end of file

A solution would be to choose an 'item-width' larger than the length of the
the largest 'label', but this won't look good if I have rather long
'labels', will it ?
So does anybody knows an other way to make it look better ?
By the way I have an other question about IconViews. IconView inherit from
Container, which I find rather logic. What I don't understand is that no
matter a IconView has icons or not, the method 'Container.get_children() '
still returns an empty list (witness the empty list printed in my short
example). This is mere curiosity, but I would be pleased to know the reason
why the list is still an empty one.

Thanks in advance for any help provided !
--
Remi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20060419/ca731d01/attachment.htm


More information about the pygtk mailing list