4

I'm in the process of writing a Gtk application. Up 'til know I have been using pygtk but because that has been deprecated in favor of PyGobject I have decided to make the switch. Back in the time of pygtk one could extend the gtk.GenericCellRenderer but this class is not longer present.

I have tried to find examples in python that uses the new API but I have failed. Can anyone show an example of a custom cell renderer that I could use as a starting point?

mandel
  • 2,921
  • 3
  • 23
  • 27
  • [here is the almost same question with correct answer][1] [1]: http://stackoverflow.com/questions/9496322/overriding-virtual-methods-in-pygobject – Alexey Aug 13 '13 at 20:06

1 Answers1

1

Apparently Gtk+ does not have any class called GtkGenericCellRenderer, is PyGtk exclusive. Since PyGObject binding is virtually the same than the C API, because the introspection technology, I suggest to use GtkCellRenderer, present in Gtk+.

from gi.repository import Gtk

class MyCellRenderer(Gtk.CellRenderer):
    def __init__(self):
        Gtk.CellRenderer.__init__(self)
eagleoneraptor
  • 1,217
  • 2
  • 12
  • 20
  • That I know, the issu is that the GtkGenericCellRenderer added a number of nice method that would make it simpler to create a custom one. My problem is that I just have experience doing so and all the How To for python are using the old bindings. – mandel Mar 07 '12 at 09:19
  • `gtk.GenericCellRenderer` was deprecated on PyGtk, you should to override the methods provided by Gtk.CellRenderer such as `render`, `activate` and `start_editing`, you need to see the documentation of this methods on the C Gtk+ documentation since the documentation generator for PyGObject still in development. – eagleoneraptor Mar 07 '12 at 16:09