Things have been going well. I did have a bit of a surprise when I added the possibility to drop files onto an open picture viewer. In C#/WPF, this is a simple event, like clicking a button. But in wxPython, one needs to instanciate a new class, wx.FileDropTarget, to do this.
All examples I found on the Web did this using two separate objects, so there was a need to have them communicate. But I thought, why not do them in the same object? This gave me the following code:
import wx class DropApp(wx.Frame, wx.FileDropTarget): # two parent classes def __init__(self): self.app = wx.App() wx.Frame.__init__(self, parent=None, title='DropFile', size=(400, 250)) wx.FileDropTarget.__init__(self) self.SetDropTarget(self) # connecting the two parent classes :-) def OnDropFiles(self, x, y, names): # overriding method from wx.FileDropTarget print 'File dropped(' + str(type(names)) + '): ' + str(names) # process the file names in the context of the wx.Frame app ! def run(self): self.Show() self.app.MainLoop() app = DropApp() app.run()It seems to work fine in my picture viewer.
Similarly for error handling. Maybe the text should name the important exceptions, but I don't need that in the example.
Email: (franšais, English, Deutsch).