Hi,
I've created a custom QLabel class which allows dropping a file onto it.
But I'm having issues with fetching the filepath of the dropped file when
dropped from anything but a Windows drive letter. So for example if you
drag and drop a file from a network share (which has not been mapped to
drive letter), I'm not getting the absolute full path. Also, on Mac OS X my
code does not seem to work at all.
I'm totally new to the whole drag and drop concept and I feel I haven't had
the time to read up on this prior to dig into code. So I'm a little lost on
the concept side of things.
Do I have to check for the filepath of the dropped file in several
different ways? This seems somewhat odd...
Any tips or ideas on how to deal with this are very much welcome.
Cheers,
Fredrik
This is the code I have currently:
class DropableQLabel(QtGui.QLabel):
def __init__(self, parent):
super(DropableQLabel, self).__init__(parent)
self.skalman = parent.skalman
self.skalman.browser = parent
self.setFixedWidth(300)
self.setFixedHeight(169)
self.setFrameShape(QtGui.QFrame.Box)
self.setAlignment(QtCore.Qt.AlignCenter)
self.setAcceptDrops(True)
def dragEnterEvent(self, event):
print 'Entered droppable area'
if event.mimeData().hasUrls():
event.acceptProposedAction()
else:
super(DropableQLabel, self).dragEnterEvent(event)
def dropEvent(self, event):
if event.mimeData().hasUrls():
for url in event.mimeData().urls():
print url.path() # this is not always an absolute filepath
event.acceptProposedAction()
else:
super(DropableQLabel,self).dropEvent(event)
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWP6rn%2B6-A8dd4p1TA6gRu3FSDw%2Bc5vWsfJ1gmfOUUWdmQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.