On 25/08/10 01:59, Robert Park wrote:
> Hi everybody, PyGTK newbie here so please don't hurt me if this
> question is too simple ;-)
>
> I'm writing a simple app that uses a ListStore/TreeView to display a
> list of files, and what I want to achieve is a list with large
> thumbnails on the left hand side and three rows of text adjacent to
> each thumbnail.
>
> So far, what I have is some code like this, which packs three
> CellRendererText's into a single TreeViewColumn.
>
> self.cell_string = gtk.CellRendererText()
> self.lat_string = gtk.CellRendererText()
> self.lon_string = gtk.CellRendererText()
>
> ...
>
> self.name_column = gtk.TreeViewColumn('Name')
> self.name_column.pack_start(self.cell_string, True)
> self.name_column.add_attribute(self.cell_string, 'text', 1)
> self.name_column.pack_end(self.lat_string, False)
> self.name_column.add_attribute(self.lat_string, 'text', 4)
> self.name_column.pack_end(self.lon_string, False)
> self.name_column.add_attribute(self.lon_string, 'text', 5)
> self.treeview.append_column(self.name_column)
>
> What happens is that TreeViewColumn acts like an HBox and the three
> CellRendererText's are arranged side by side left-to-right like this:
>
> [thumbnail] filename.jpg foo bar
>
> What I really want is to make TreeViewColumn act like a VBox instead,
> so that I get output like this:
>
> filename.jpg
> [thumbnail] foo
> bar
>
> How do I go about doing this?
>
> Thanks in advance!
>
Hi Robert,
> Hi everybody, PyGTK newbie here so please don't hurt me if this
> question is too simple ;-)
No problem :) This confused me when I was a 'newbie' so I don't blame you.
Instead of using 3 CellRendererText's, all you need to do is use one,
and then when you append an item to the model of the treeview
(gtk.ListStore etc.) all you must do is:
model.append([thumbnail, "filename.png\nfoo\nbar"])
The '\n' means that it causes a line break, and so filename.jpg, foo and
bar should be on separate lines.
Hope this helps :)
--
Andrew
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/