[pygtk] Drag and drop: retaining selection?

Andrew Conkling andrew.conkling at gmail.com
Thu Mar 9 11:48:11 WST 2006


I'm trying to set up DnD in my program to retain the selection after
dragging, but I can't seem to get it work.  We have some rather crazy
code to handle the drag and drop itself (which I can paste but I don't
think it's relevant) because the TreeModel simply mirrors a backend
list which we have to update.  In Glade, I've connected 'drag-end' to
my after_drag_drop callback, and set it to call *after*.  Here's the
callback:

def after_drag_drop(self, treeview, drag_context):
	model = treeview.get_model()
	sel = treeview.get_selection()
	# self._selected is created in the DnD code, and is simply a list of
selected paths.
	for path in self._selected:
		sel.select_path(path)

The treeview's selection mode is set to gtk.SELECTION_MULTIPLE.

It seems like it works (just eyeballing it), because the selection
'sticks' for a moment, but then the selected rows are unselected.  Any
idea what would be causing this or what other code I could paste to
help figure this out?

Thanks a lot,
Andrew

--
http://aconkling.blogspot.com


More information about the pygtk mailing list