Thanks to some help already from this list, I can drag and drop between
treeviews, but I want to make my app more comprehensive. It would be good if
I could control where in a treeview, a row from another treeview could be
dropped.

For example if I have a 2 level treeview with players in teams, and I have
another treeview with "new players", and I want to be able to drag the "new
player" rows into teams using drag and drop.

But I do not want to allow dropping "new players" into the top level (which
is used for teams), or dropping new players as children of other players.

Ideally, as you are dragging over certain rows the cursor would change to
indicate whether the drop is allowable to that location or not.

Is this sort of functionality accommodated? Or, am I dreaming :) ?



My adapted code below restricts drops so that only "drop into"'s work, but
the source row disappears regardless. I cannot see where in my code makes
the row disappear from the source treeview in my feeble attempt:

 def drag_data(self, treeview, context, selection, target_id, time):
        treeselection = treeview.get_selection()
        model, iter = treeselection.get_selected()
        data = model.get_value(iter, 0)
        selection.set(selection.target, 8, data)

    def drop_data(self, treeview, context, x, y, selection, info, time):

        model = treeview.get_model()
        data = selection.data
        dropinfo = treeview.get_dest_row_at_pos(x, y)

        if dropinfo:
            print dropinfo
            path, position = dropinfo
            iter = model.get_iter(path)
            print "depth = "+ str(model.iter_depth(iter))
            if (position == gtk.TREE_VIEW_DROP_BEFORE):
                print "no dropping at high level"
                #model.insert_before(None,iter, [data])
            else:
                if (position == gtk.TREE_VIEW_DROP_INTO_OR_AFTER):
                    model.insert(iter,0, [data])
                else:
                    print "no dropping at high level"
                    #model.insert_after(None,iter, [data])
        else:
            #model.append([data])
            print "no dropping at high level"
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to