Yo lo hago de esta forma:
I do it this way:
my_widget = gtk. . . .
my_widget.drag_source_set(gtk.gdk.BUTTON1_MASK, targets,
gtk.gdk.ACTION_MOVE)
. . .
my_vbox.drag_dest_set(gtk.DEST_DEFAULT_ALL, targets,
gtk.gdk.ACTION_MOVE)
my_vbox.connect("drag-drop", self.drag_drop)
. . .
def drag_drop(self, destino, drag_context, x, y, cosas):
objeto = drag_context.get_source_widget()
if objeto.get_parent() == destino: return
objeto.get_parent().remove(objeto)
destino.pack_start(objeto, False, False, 1)
targets = [("Moviendo", gtk.TARGET_SAME_APP, 1)]
2012/7/9 Paul Lange <[email protected]>
> Hey,
>
> In an application I have a gtk.VBox filled with own widgets. The plan is
> to let the user reorder these widgets per drag and drop.
>
> These widgets are set as the drag_sources and the parent VBox as the
> drag destination. Now I need to somehow inform the VBox which child
> widget was moved. If I understood correctly it's SelectionData what is
> used for that.
> I would like to add a link of the child to SelectionData to be able to
> reorder the children as the user wishes (if you see better alternatives
> here, please tell me)
> However the documentation states: "In PyGTK the selection data is always
> a string...". Does that mean that I need to convert my widgets to a
> string and then back to a widget for the drag and drop process?
> Or do I miss another way or best practice to exchange this information?
>
> Thanks for your help!
> Paul
>
> _______________________________________________
> python-hackers-list mailing list
> [email protected]
> https://mail.gnome.org/mailman/listinfo/python-hackers-list
>
_______________________________________________
python-hackers-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/python-hackers-list