Gtk treeview: place image buttons in rows

For each row in my tree structure, I want 4 image buttons next to each other. They will act as switches, and only one of them can be activated at a time. Each button has an image of 'on' and 'off'.

How can I do it? I figured out how to put images there, and how to put togglebuttons buttons, but it seems to take a few more efforts, since there is no pre-created cellrenderer that does what I want.

Basically what I decided, the problem is how to make the image in gtk.treeview accessible. any ideas?

+6
python gtk pygtk gtktreeview
source share
3 answers

Take a look at this ' http://www.daa.com.au/pipermail/pygtk/2010-March/018355.html '. It shows how to activate gtk.CellRendererPixbuf and connect to a click event signal.

 cell = CellRendererPixbufXt() cell.connect('clicked', func) 

Update

As indicated in this answer, or the link provided does not work as advertised. It skips the do_activate method, which should emit a click signal. Once this is done, the cell.connect socket will work.

Sorry if this answer is misleading.

+1
source share

Here is the short version without kiwi requirement.

 class CellRendererClickablePixbuf(gtk.CellRendererPixbuf): __gsignals__ = {'clicked': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)) } def __init__(self): gtk.CellRendererPixbuf.__init__(self) self.set_property('mode', gtk.CELL_RENDERER_MODE_ACTIVATABLE) def do_activate(self, event, widget, path, background_area, cell_area, flags): self.emit('clicked', path) 
+2
source share

Here is what worked for me:

 class CellRendererClickablePixbuf(gtk.CellRendererPixbuf): gsignal('clicked', str) def __init__(self): gtk.CellRendererPixbuf.__init__(self) self.set_property('mode', gtk.CELL_RENDERER_MODE_ACTIVATABLE) def do_activate(self, event, widget, path, background_area, cell_area, flags): self.emit('clicked', path) 
0
source share

All Articles