leamas
leamas

Reputation: 149

GTk3 python Gtk.CellRendererText() -> Warning Refusing to add the same cell renderer

As heading says: a small seemingly ok snippet generates 3 warnings:

Gtk-WARNING **: Refusing to add the same cell renderer to a GtkCellAreaBox twice

The code:

from gi.repository import Gtk
renderers = {}
for ix, col in enumerate(['vendor', 'conf', 'supports']):
    renderers[col] = Gtk.CellRendererText()
    column = Gtk.TreeViewColumn(col, renderers[col], text=ix)
    column.pack_start(renderers[col], True)

It seems to work anyway in it's natural context, but I'm not really happy with these warnings... tested with both python2 and python3, no difference (as expected)

Gtk version: gtk3-3.10.6-1.fc20.i686

Any hint out there?

--alec

Upvotes: 0

Views: 212

Answers (1)

luciomrx
luciomrx

Reputation: 1195

Just use 1 Gtk.CellRenderer, unless you want specific property to be added on different renderers.

On the matter of the warning, the doc said (if i remember correctly), instantiate Gtk.TreeViewColumn (*args) is equal with :

  1. Gtk.TreeViewColumn.set_title (title)
  2. Gtk.TreeViewColumn.pack_start (renderer, bool)
  3. Gtk.TreeViewColumn.set_attributes (*args) > not have that function on python binding, I think.

So, the warning is actually correct, you did pack the renderer twice, by invoke "pack" method again. Just remove the Gtk.TreeViewColumn.pack_start/end method.

Upvotes: 1

Related Questions