Created
          April 8, 2023 17:48 
        
      - 
      
 - 
        
Save ssokolow/30e0cf931e80ab5a95ba1db9a7b23613 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
ssokolow created this gist
Apr 8, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ #!/usr/bin/python """Quit and dirty port of the old PyGTK dragtargets.py to PyGObject""" import gi gi.require_version('Gtk', '3.0') gi.require_version('Gdk', '3.0') from gi.repository import Gdk, Gtk def motion_cb(wid, context, x, y, time): Gdk.drag_status(context, Gdk.DragAction.COPY, time) return True def drop_cb(wid, context, x, y, time): targets = "" for t in context.list_targets(): targets = targets + str(t) + "\n" wid.drag_get_data(context, t, time) print(targets) label.set_text(targets) #l.set_text('\n'.join([str(t) for t in context.targets])) #print('\n'.join([str(t) for t in context.targets])) #a = wid.drag_dest_find_target(context, t) #context.finish(True, False, time) return True def drag_received_cb(widget, drag_context, x, y, selection_data, info, time): print("Target: {}".format(selection_data.get_target())) print("Data: {}".format(selection_data.get_data())) w = Gtk.Window() w.set_size_request(200, 150) w.drag_dest_set(0, [], 0) w.connect('drag_motion', motion_cb) w.connect('drag_drop', drop_cb) w.connect('drag_data_received', drag_received_cb) w.connect('destroy', lambda w: Gtk.main_quit()) label = Gtk.Label() w.add(label) w.show_all() Gtk.main()