Results 1 to 3 of 3

Thread: Python gtk3 Drag and drop

  1. #1
    Join Date
    Jun 2011
    Location
    United Kingdom
    Beans
    Hidden!
    Distro
    Lubuntu Development Release

    Python gtk3 Drag and drop

    OK, here's the code I'm trying to run:

    PHP Code:
    #!/usr/bin/python

    from gi.repository import Gtk

    class UI():
        
    def __init__(self):
            
            
    Gtk.Window()
            
    w.set_default_size(600400)
            
    lab Gtk.Label("drop here!")
            
    lab.connect("drag-data-received"self.on_drag_data_received)
            
    w.add(lab)
            
    w.connect("destroy"Gtk.main_quit)
            
    w.show_all()
            
    Gtk.main()

        
    def on_drag_data_received(widgetdrag_contextxydatainfotime):
            print(
    "Hello World!")

    test UI() 
    However, the window produced is not sensitive to dnd, nor does it print anything if I drop anything on it. What am I doing wrong?

  2. #2
    Join Date
    Aug 2007
    Location
    UK
    Beans
    427
    Distro
    Ubuntu UNR

    Re: Python gtk3 Drag and drop

    Adapted from one of my programs:
    Code:
    droptargets = [
        ('text/plain', 0, 0),
        ('TEXT', 0, 1),
        ('STRING', 0, 2),
        ('text/uri-list', 0, 3)
        ]
    
    dropwidget.enable_model_drag_dest(droptargets, gtk.gdk.ACTION_DEFAULT)

  3. #3
    Join Date
    Jun 2011
    Location
    United Kingdom
    Beans
    Hidden!
    Distro
    Lubuntu Development Release

    Re: Python gtk3 Drag and drop

    Thanks, but can you explain a little more on that? I'm a dnd newb.

    I'm just trying to get the filename of files/folders dropped onto a label. I'm sure it that it can't be that hard...

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •