Guest User

Untitled

a guest
Jan 16th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import pygtk
  2. pygtk.require('2.0')
  3. import gtk
  4.  
  5. w = gtk.Window()
  6. w.drag_set_set(0, [], 0)
  7. w.connect('drag_motion', motion_cb)
  8. w.connect('drag_drop', drop_cb)
  9. w.connect('drag_data_received', got_data_cb)
  10. w.connect('destroy', lambda w: gtk_main_quit())
  11.  
  12. l = gtk.Label()
  13. l.set_text('Drag File Here')
  14. w.add(l)
  15. w.show_all()
  16. gtk.main()
  17.  
  18. def motion_cb(wid, context, x, y, time):
  19. context.drag_status(gtk.gdk.ACTION_COPY, time)
  20. return True
  21.  
  22. def drop_cb(wid, context, x, y, time):
  23. wid.drag_get_dta(context, context.targets[-1], time)
  24. return True
  25.  
  26. def got_data_cb(wid, context, x, y, data, info, time):
  27. # the following line returns a URI? I want the absolute file path
  28. print data.get_text()
Add Comment
Please, Sign In to add comment