[pygtk] Re: Icon in TreeStore... continued
Muhammad Ali
ali.jan at gmail.com
Thu Mar 31 18:03:12 WST 2005
Hi again,
I am trying this example from the faq:
http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq13.014.htp
*******************************************************************************
folder = gtk.gdk.pixbuf_new_from_file('folder.png')
folder_open = gtk.gdk.pixbuf_new_from_file('folder-open.png')
def init_model(self):
store = gtk.TreeStore(gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, str)
# Fill the model with some silly sample data.
for p in xrange(10):
parent = store.append(None, (MyTree.folder, MyTree.folder_open,
'Parent %s' % p))
for c in xrange(5):
store.append(parent, (MyTree.folder,
MyTree.folder_open, 'Child %s' % c))
self.set_model(store)
def init_view_columns(self):
col = gtk.TreeViewColumn()
col.set_title('Silly Example')
render_pixbuf = gtk.CellRendererPixbuf()
col.pack_start(render_pixbuf, expand=False)
col.add_attribute(render_pixbuf, 'pixbuf-expander-closed', 0)
col.add_attribute(render_pixbuf, 'pixbuf-expander-open', 1)
render_text = gtk.CellRendererText()
col.pack_start(render_text, expand=True)
col.add_attribute(render_text, 'text', 2)
self.append_column(col)
*******************************************************************************
When i run this, only the icons for the parent appear. They do not
appear for the children. Furthermore, if i try to add something after
i make an object like:
*******************************************************************************
tr = MyTree()
store = tr.get_model()
parent = store.append(None, (MyTree.folder, MyTree.folder,'outside'))
*******************************************************************************
The new node is added but without the icon.
Why don't the children show their icon? and Why does the 'outside'
node added later has the icon missing?
Thanks,
Ali
On Thu, 31 Mar 2005 12:22:18 +0500, Muhammad Ali <ali.jan at gmail.com> wrote:
> Okay sorry for the bother, I am stupid. Append of tree store needs to
> be passed an additional parameter.
>
>
> On Thu, 31 Mar 2005 11:38:35 +0500, Muhammad Ali <ali.jan at gmail.com> wrote:
> > Hi,
> >
> > This is related to the FAQ entry, How do I put Icons in a TreeView:
> > http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq13.006.htp
> >
> > The problem is that the example uses a ListStore instead of a
> > TreeStore and then appends the icon to it. When I use the same append
> > method with the TreeStore, it throws a TypeError exception:
> >
> > TypeError: parent must be a GtkTreeIter or None
> >
> > But the same method works fine with a ListStore. How do I put Icons in
> > a TreeView using TreeStore?
> >
> > Thanks...
> >
> > Regards,
> > Ali
> >
>
More information about the pygtk
mailing list