|
Hi,
I have a sizer filled with picture thumbnais, loaded from the filesystem. And another window has a FileDropTarget where files from the filesystem can droppen into. My question: is there a way to create a dropSource programatically that behaves like a dropped file from the filesystem? So that my sizer, that contains the images can create the dropSources in the same way as the Platform does it for the files from the explorer. thanks, Alex Greif ________________________________________ http://www.fotobuch-xxl.de/ |
|
Alex Greif wrote:
> Hi, > > I have a sizer filled with picture thumbnais, loaded from the > filesystem. And another window has a FileDropTarget where files from > the filesystem can droppen into. > My question: > is there a way to create a dropSource programatically that behaves > like a dropped file from the filesystem? So that my sizer, that > contains the images can create the dropSources in the same way as the > Platform does it for the files from the explorer. Yes, something like this: dataobj = wx.FileDataObject() dataobj.AddFile(filename) source = wx.DropSource(window) source.SetData(dataobj) source.DoDragDrop() -- Robin Dunn Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython! |
|
Robin,
1) your code works fine for normal paths, but makes problems when the path contains eg. german Umlaute like ö, ä, ß ... Such paths disappear somehow. one of my picture has the following path: /Volumes/data/tmp/_öäü/tempöäß.jpg and I put the utf8 encoded string in the DataObject dataobj = wx.FileDataObject() dataobj.AddFile(self.picture.getFilePath().encode('utf-8')) source = wx.DropSource(self) source.SetData(dataobj) result = source.DoDragDrop(wx.Drag_AllowMove) my dropTarget looks like: class OglPictureDropTarget(wx.FileDropTarget): def __init__(self, targetWin): wx.FileDropTarget.__init__(self) self.targetWin = targetWin def OnDropFiles(self, x, y, filenames): print "-->OglPictureDropTarget.OnDropFiles() filenames:", filenames .... The Problem: Unfortunaltely the filenames list is always empty in such cases, when the path contains non-standard characters. output: -->OglPictureDropTarget.OnDropFiles() filenames: [] Is there a workaround? It seems to be a bug 2. BTW another problem is that even if I add miltiple files, only the first is delivered to the drop target. sample: dataobj.AddFile(u"/Volumes/data/tmp/chess.jpg".encode('utf-8')) dataobj.AddFile(u"/Volumes/data/tmporder.gif".encode('utf-8')) deliveres only -->OglPictureDropTarget.OnDropFiles() filenames: [u'/Volumes/data/tmp/chess.jpg'] This seems to be a bug too, because the docs for AddFile say: "Adds a file to the list of files represented by this data object." cu Alex. On 1/15/06, Robin Dunn <[hidden email]> wrote: > Alex Greif wrote: > > Hi, > > > > I have a sizer filled with picture thumbnais, loaded from the > > filesystem. And another window has a FileDropTarget where files from > > the filesystem can droppen into. > > My question: > > is there a way to create a dropSource programatically that behaves > > like a dropped file from the filesystem? So that my sizer, that > > contains the images can create the dropSources in the same way as the > > Platform does it for the files from the explorer. > > Yes, something like this: > > dataobj = wx.FileDataObject() > dataobj.AddFile(filename) > source = wx.DropSource(window) > source.SetData(dataobj) > source.DoDragDrop() > > > -- > Robin Dunn > Software Craftsman > http://wxPython.org Java give you jitters? Relax with wxPython! > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > > -- Alex Greif ________________________________________ http://www.fotobuch-xxl.de/ |
| Powered by Nabble | Edit this page |
