From: Bill B. <bil...@pe...> - 2006-02-18 11:50:28
|
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: <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] </code> and then later (in my GUI class): <code> class GUI(model.Background): def on_initialize(self, event): self.fileList = self.components.fileList dropTarget = FileDropTarget(self.fileList) self.fileList.SetDropTarget(dropTarget) </code> 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): <code> self.fileList.Bind(wx.EVT_DROP_FILES, self.on_fileList_DropFiles) </code> and then later (in my code) I have a method that looks like this: <code> def on_fileList_DropFiles(self, event): print 'files have been dropped' </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? In case it matters, I'm also binding this event to the fileList: <code> self.fileList.Bind(wx.EVT_RIGHT_DOWN, self.on_fileList_RightDown) </code> and this event works fine. Here's my specifications: OS: Windows 2000 Pro SP4 PythonCard: 0.8.1 Python: 2.4.1 wxPython: 2.6.1.0 Thanks, Bill |