PyGTK: Doubleclick on CellRenderer
In my PyGTK application, I am currently using "editable" to make the cells editable. But since the content of my cell is sometimes really very large, I want to ask the user to make changes to the new window when he double-clicks on the cell. But I couldn't figure out how to hook up double-clicks to a specific host - I don't want to edit the entire row, and I also don't want to set this callback for the entire row, only for columns where too long content might occur. How can I do this with CellRendererText () or something similar.
My code generating cells is as follows:
cols[i] = gtk.TreeViewColumn(coltitle)
cells[i] = gtk.CellRendererText()
cols[i].pack_start(cells[i])
cols[i].add_attribute(cells[i], 'text', i)
cols[i].set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
cols[i].set_fixed_width(100)
cells[i].set_property('editable', True)
cells[i].connect('edited', self.edited, (i, ls))
cols[i].set_resizable(True)
mytreeview.append_column(cols[i])
Thanks!
a source to share
I believe this is not possible directly. However, you can connect to button-press-event
on gtk.TreeView
. Then when event.type
equal gtk.gdk._2BUTTON_PRESS
, convert x
and y
to the tree location using gtk.TreeView.get_path_at_pos()
. This will return a tree path indicating the string and object gtk.TreeViewColumn
that was clicked on.
a source to share