Re: Unable to get CellRenderer working correctly

On 10 January 2013 16:57, Jonathan Ballet <jon multani info> wrote:
> Hi,
> I tried to customize a Gtk.TreeColumn by setting a "cell data function"
> to convert the value from my model to something more useful for my
> renderer (converting a path nam to an actual pixbuf).
> It wasn't working so I tried more or less the same with a much simpler
> model, but it still doesn't work. This is basically what I tried:
>     def cell_data_func(column, cell, model, iter, data):
>         cell.set_property('text', model.get(iter, 0))
>     store = Gtk.ListStore(str)
>     view = Gtk.TreeView(store)
>     column = Gtk.TreeViewColumn("Value")
>     renderer = Gtk.CellRendererText()
>     column.set_cell_data_func(renderer, cell_data_func)
>     view.append_column(column)
>     ...

You're not adding your CellRenderer to the column (something the
TreeViewColumn helpfully does automatically). You need something like

column = Gtk.TreeViewColumn("Value")
renderer = Gtk.CellRendererText()
column.pack_start(renderer, True)
column.set_cell_data_func(renderer, cell_data_func)

and so forth

Neil Muller
drnlmuller gmail com

I've got a gmail account. Why haven't I become cool?

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]