Hi,
I’m trying to create a DropTarget accepting both file and URL objects. (See attached code)
However, on Windows I run into a strange problem with this constructor probably because wx.URLDataObject has a very different inheritance tree. On all other platforms wx.URLDataObject is derived from wx.TextDataObject which can be added to a wx.DataObjectComposite because it is derived from wx.DataObjectSimple.
It is interesting to note that Robin Dunn back in 2003 suggested that “because URLDataObject is already a composite, you can try just Add()ing the FileDataObject to it”. (https://groups.google.com/forum/#!searchin/wxpython-users/wx.URLDataObject/wxpython-users/K5tR-gtZbMI/FfgNZubRJp0J)
However, when i run “print(inspect.getmro(wx.URLDataObject))” using wxPython4.0.1/Python3.6/Win10 i get:
(<class ‘wx._core.URLDataObject’>, <class ‘wx._core.DataObject’>, <class ‘sip.wrapper’>, <class ‘sip.simplewrapper’>, <class ‘object’>)
Hence wx.URLDataObject is not wx.DataObjectComposite nor wx.DataObjectSimple on this platform. However, the official wxPython documentation
(https://wxpython.org/Phoenix/docs/html/wx.URLDataObject.html)
claims in a note that on Windows wx.URLDataObject is derived from wx.DataObjectComposite. As far as I can see this is wrong.
What is the correct solution to allow both URL and file drop to the very same widget in Phoenix valid on all platforms?
Just out of curiosity (I’m not an expert): why do we need to maintain a very different class hierarchy for wx.URLDataObject on Windows? Could we aim for a platform independent class hierarchy in Phoenix?
Thanks for all the help you can provide!
Jens
example.py (328 Bytes)