Arrastar e soltar GTK em Python - Obter URL
Eu estou criando um pequeno aplicativo deve ser capaz de receber URLs. Se a janela de aplicativos estiver aberta, será possível arrastar um link de um navegador e soltá-lo no aplicativo - e o aplicativo salvará o URL em um banco de dados.
Estou criando isso em Python / GTk. Mas estou um pouco confuso sobre a funcionalidade de arrastar e soltar nela. Então, como é?
Algum exemplo de código para implementar arrastar / soltar (meu aplicativo usa um pouco desse código) ...
import pygtk
pygtk.require('2.0')
import gtk
# function to print out the mime type of the drop item
def drop_cb(wid, context, x, y, time):
l.set_text('\n'.join([str(t) for t in context.targets]))
# What should I put here to get the URL of the link?
context.finish(True, False, time)
return True
# Create a GTK window and Label, and hook up
# drag n drop signal handlers to the window
w = gtk.Window()
w.set_size_request(200, 150)
w.drag_dest_set(0, [], 0)
w.connect('drag_drop', drop_cb)
w.connect('destroy', lambda w: gtk.main_quit())
l = gtk.Label()
w.add(l)
w.show_all()
# Start the program
gtk.main()