[pygtk] Treeview drag'drop chap14

John Finlay finlay at moeraki.com
Wed Oct 5 05:10:03 WST 2005

Doug Quale wrote:

>mc collilieux <mccnews at free.fr> writes:
>>and 3rd, when I add a gtk.gdk.Pixbuf to the models, I did not make the
>>drag'drop because i dont know how transform an image in string. Here
>>is why, i think i have not understand very well this section of
>Transforming the data from string to integer is the right way to do
>it.  Drag data is always a string, or just a sequence of bytes.  The
>drag type tells the target how to interpret the string data, so you
>would use different drag types to distinguish UTF-8 and UTF-16, for
>You should be able to drag and drop pixbufs too.  Probably someone
>here will supply an example you can study.  Often MIME types are used
>as the drag type strings, so 'image/pixbuf' might be the appropriate
>drag type to use here.
Just an addition to Doug's excellent response. In PyGTK 2.6 the 
set+pixbuf() and get_pixbuf() methods were added to the SelectionData 
class for DND of pixbufs. Also look at the 
gtk.target_list_add_image_targets() function and the 
gtk.SelectionData.targets_include_image() method for additional help. If 
you are using PyGTK 2.4 or lower then it's mcuh harder since you would 
have to convert the pixbuf to a string and back to drag and drop it and 
you probably can only do pixbuf DND within the same app.


More information about the pygtk mailing list