Hello,
Every time I drag a text document onto my application's text buffer,
it loads the document fine, but then, it appends the document's URI at
the end of the document. I'm clueless as to why this is happening or
what I should do to prevent it. Your help is sincerely appreciated.
For some odd reasons, it seems as if my drag and drop handlers are
being called twice. Here are a few snippets of the code in question:
...
...
...
self.TARGET_TYPE_TEXT = 80
self.toBuffer = [("text/plain", 0, self.TARGET_TYPE_TEXT )]
self.textView.drag_dest_set(gtk.DEST_DEFAULT_ALL, self.toBuffer,
gtk.gdk.ACTION_MOVE)
self.textView.connect("drag_motion", self.drag_callback)
self.textView.connect("drag_drop", self.drop_callback)
self.textView.connect("drag_data_received",
self.data_received_callback)
....
...
...
#Drag and Drop Callbacks
def drag_callback(self, wid, context, x, y, time):
context.drag_status(gtk.gdk.ACTION_MOVE, time)
def drop_callback(self, wid, context, x, y, time):
self.textBuffer.set_text("")
def data_received_callback(self, widget, drag_context, x, y, selection_data,
target_type, time):
if target_type == self.TARGET_TYPE_TEXT:
data = selection_data.get_text()
filename = gnomevfs.get_local_path_from_uri(data)
realfile = filename[0:-1]
self.loadFile(realfile)
else:
print "couldn't not load file"
Your help is appreciated.
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/