[pygtk] Re: Treeview multiple row DnD

Stephen Kennedy stevek at gnome.org
Tue Jun 27 14:50:51 WST 2006


> Can someone give me a hint on how to drag multiple items from a
> gtk.TreeView? When I select mutliple rows and then click on one of them to
> begin the drag all the other selected rows are lost.
>
> I noticed that some Gtk+ apps written in C (file-roller for instance) use
> eggtreemultidnd.c
> (http://stuff.mit.edu/afs/dev/source/src-current/third/file-roller/src/eggtreemultidnd.c
> ) to get achieve this behaviour, is there no way to do this in Python?

Return True from the button press event of the tree to stop the
default handler (which handles selection) from being run. e.g. here's
some code which pops up a context menu on right mouse button and
replaces the selection only if there is one item selected.

    def on_button_press_event(tree, event):
        if event.button==3:
            popupMenu(event)
            return _count_selected_treepaths(tree) != 1
        return False

Stephen.


More information about the pygtk mailing list