From: Alex T. <al...@tw...> - 2006-02-18 15:43:43
|
Bill Burns wrote: > I'm testing out adding drag and drop capabilities to my PythonCard app. > I'm looking to have files dropped onto a wxList. > > So far I have code like this: > > <snip> > The above works fine. I can drop the files on the wxList control and the > filenames are appended to the List. > > Now, I need to know when files have been dropped on the List, so I added > this line (under on_initialize): > Why not simply do this in the OnDropFiles() function, i.e. <code> class FileDropTarget(wx.FileDropTarget): def __init__(self, obj): wx.FileDropTarget.__init__(self) self.obj = obj def OnDropFiles(self, x, y, filenames): [self.obj.Append(f) for f in filenames] print "component", self.obj.name, "received files", filenames --- THIS </code> > When I drop files on the List, I can't seem to get the DROP_FILES event > to fire. IOW, my program never prints 'files have been dropped'. > > Does anyone know what I'm doing wrong? > I don't. However, I think the event mechanism for dropping is different from the usual one. If you could simply bind to EVT_DROP_FILES, then I think there'd be no need for the SetDropTarget complexity, would there? However, I do know for sure that the above change works and prints out the name of the component on which they've been dropped, and (just the new) file names on a drop event, so it can be used even if you have multiple drop targets. -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 267.15.11/264 - Release Date: 17/02/2006 |