1

I am using PyQt4, Python 2.7, Qt 4.8 on Mac OSX Yosmite. I appear to have Drag-n-Drop working, can process drop event etc. If I drop a file in and print the path I get values like /.file/id=6571367.11512812 Using this file-id I can't seem to open/process the file. Here is the dropEvent() method. Any ideas how to get the true file path?

def dropEvent(self, event):
    for url in event.mimeData().urls():
        path = url.path() # also tried url.toLocalFile().toLocal8Bit().data()
        print path
        if os.path.isfile(path):
            print "found"
        else:
           print "not found"

It seems to be related to https://bugreports.qt.io/browse/QTBUG-40449 which recommends upgrading to Qt5, which is will require a significant effort as I have vtk5, opencv, qgis and few others dependent on Qt4.

Anyone know of a workaround or a fix?

Michael
  • 559
  • 6
  • 15
  • So your question is actually: how do I convert an osx `fileid` to a `filepath` using python? Presumably someone who knows [PyObjC](https://pythonhosted.org/pyobjc/) should be able to answer that, so maybe you should reformulate your question with that in mind. – ekhumoro Oct 15 '15 at 16:30
  • @ekhumoro, thanks. Changed question and added another tag. – Michael Oct 16 '15 at 07:28
  • 1
    I recently answered this (I hadn't found this question before) at http://stackoverflow.com/questions/34689562/pyqt-mimedata-filename/34731190#34731190 – Ethan Kay Jan 11 '16 at 21:17
  • Awesome. Above link to code works for me. Thanks. – Michael Jan 12 '16 at 23:20

0 Answers0