[pygtk] Drag and drop in PyGI
Osmo Salomaa
otsaloma at iki.fi
Tue Jul 26 02:54:50 WST 2011
Hi,
I'm migrating an application to Python 3, GTK+ 3 and the PyGI bindings.
I'm having trouble with drag and drop, which I would need for opening
files dragged from a file browser. I have the following minimal example,
which I have translated my old code to the new APIs, but it doesn't seem
to work. The Window is not receiving any drag events. Am I using
Gtk.TargetEntry and friends correctly?
#!/usr/bin/env python3
from gi.repository import Gdk
from gi.repository import Gtk
window = Gtk.Window()
window.drag_dest_set(Gtk.DestDefaults.ALL,
[Gtk.TargetEntry.new("text/uri-list", 0, 0)],
Gdk.DragAction.COPY)
window.connect("drag-data-received", lambda *args: print(args))
window.resize(500, 500)
window.show_all()
window.connect("delete-event", Gtk.main_quit)
Gtk.main()
--
Osmo Salomaa <otsaloma at iki.fi>
More information about the pygtk
mailing list