[Python-es] Añadir imagenes propias en un treeview
Daniel Francis
santiago.danielfrancis en gmail.com
Dom Ene 8 19:50:32 CET 2012
Una opción es esta:
self.liststore = gtk.ListStore(str, gtk.gdk.Pixbuf, str, 'gboolean')
abrir = gtk.gdk.pixbuf_new_from_file_at_size("./abrir.png", 30, 30)
self.liststore.append(['Open fg ', abrir, 'Open a File', True])
El 08/01/12, Jose Sanchez <jose.sanchez86 en hotmail.es> escribió:
>
> Hola:
>
> Me gustaria saber como cambiar las imagenes que salen del propio SO a unas
> propias echas por mi.
>
> Esto es parte del codigo de un ejemplo que he encontrado en el que muestra
> imagenes pero no se como ponerlo para que muestre unas hechas por mi:
>
> # create a liststore with one string column to use as the model
> self.liststore = gtk.ListStore(str, str, str, 'gboolean')
>
> # create the TreeView using liststore
> self.treeview = gtk.TreeView(self.liststore)
>
> # create the TreeViewColumns to display the data
> self.tvcolumn = gtk.TreeViewColumn('Pixbuf and Text')
>
> # add a row with text and a stock item - color strings for
> # the background
> self.liststore.append(['Open fg ', gtk.STOCK_OPEN, 'Open a File',
> True])
> self.liststore.append(['Newfg fg', gtk.STOCK_NEW, 'New File', True])
> self.liststore.append(['Print fgfg', gtk.STOCK_PRINT, 'Print File',
> False])
>
> ¿Que debo poner en gtk.STOCK_OPEN para que salga una imagen propia ?
>
--
_____ _ _ _______ _
(____ \ (_) | | (_______) (_)
_ \ \ ____ ____ _ ____| | _____ ____ ____ ____ ____ _ ___
| | | / _ | _ \| |/ _ ) | | ___) ___) _ | _ \ / ___) |/___)
| |__/ ( ( | | | | | ( (/ /| | | | | | ( ( | | | | ( (___| |___ |
|_____/ \_||_|_| |_|_|\____)_| |_| |_| \_||_|_| |_|\____)_(___/
Más información sobre la lista de distribución Python-es