GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Mar 29, 2015 7:25 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Drag and drop documentation (PyGObject)
PostPosted: Tue Jan 13, 2015 10:15 pm 
Offline
Familiar Face

Joined: Mon Mar 31, 2014 9:59 pm
Posts: 18
I am trying to understand the documentation about drag and drop at: https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/TreeView.html

I want to set up drag and drop so the Treeview (Liststore) can receive data from other programs like spreadsheets. Having looked at this old PyGTK example (http://www.pygtk.org/pygtk2tutorial/sec-TreeViewDragAndDrop.html) I know I should set up this method:

Code:
TreeView.enable_model_drag_dest(targets, actions)


and that requires these two things:

Code:
Gtk.TargetEntry(target, flags, info)
Gdk.DragAction(2)


I think I understand DragAction, which gets a 2 to indicate that the data will be copied. But I don't understand what to input for TargetEntry and TargetFlags. The PyGTK example uses these 2 snippets. Is there a better documentation for what these values mean?

Code:
TARGETS = [
          ('MY_TREE_MODEL_ROW', gtk.TARGET_SAME_WIDGET, 0),
          ('text/plain', 0, 1),
          ('TEXT', 0, 2),
          ('STRING', 0, 3), ]


Code:
self.treeview.enable_model_drag_source( gtk.gdk.BUTTON1_MASK,
                                                   self.TARGETS,
                                                   gtk.gdk.ACTION_DEFAULT|
                                                   gtk.gdk.ACTION_MOVE)


Edit 1:

Some progress. Using this code I can drag the items, but I am not catching the drag event correctly:

Code:

        Gtk.TreeView.__init__(self, store)
        targets = []
        self.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK,
            targets, Gdk.DragAction.DEFAULT|Gdk.DragAction.MOVE)
        self.enable_model_drag_dest(targets, Gdk.DragAction.DEFAULT)


_________________
Setup: GTK 3.12, Python 3.4, Glade 3.18, Matplotlib 1.4, Ubuntu 14.10 (64bit) and Gedit. (http://gtk3-matplotlib-cookbook.readthedocs.org)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group