[pygtk] inconsistency in treeview dnd behaviour in a certain case
dickson at permanentmail.com
Fri Aug 6 10:34:39 WST 2004
On Thu, 29 Jul 2004 00:42:54 +0200, Abel Daniel wrote:
> I have a 'feature' I discovered and can't decide whether to file a
> bug, or a faq entry or what.
> Make a TreeView which has some rows, but there is space at the end
> where there are no rows (i.e. the window/scrolledwindow is bigger than
> the TreeView). Enable drag&drop. Drag a row so that it would be
> dropped on the empty space at the end. Notice that there _is_ a line
> after the last row indicating that it will be dropped there. Drop the
> row, and notice that the app raises an exception and doesn't do the
> drop. (As an example app the one provided in
> is perfect.)
> Reason: the 'drag-data-received' signal's handler uses
> TreeView.get_dest_row_at_pos(x, y) to find out the place of the
> drop. In this case, however, as the drop position doesn't have rows
> underneath, it returns None.
> And TreeView.get_drag_dest_row() returns None in this case, too. (Try
> it out by catching the exception in the above example code and
> printing the values)
> The real suprise is that in the UI, the line appears, so one would
> guess the drop should work, and so should .get_dest_row_at_pos(x, y),
> but it doesn't.
I ran into this problem, my solution was:
temp = treeview.get_dest_row_at_pos(x, y)
if temp != None:
path, pos = temp
path, pos = (len(model)-1,), gtk.TREE_VIEW_DROP_AFTER
With this change, I could DnD into the empty rows at the bottom of the
I just updated the FAQ example that uses the first line (10.34) for another
reason, I'll go back there and add this code.
More information about the pygtk