Skip to content

Instantly share code, notes, and snippets.

@srinikom
Created May 4, 2012 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srinikom/2592661 to your computer and use it in GitHub Desktop.
Save srinikom/2592661 to your computer and use it in GitHub Desktop.
import sys
from PySide import QtCore, QtGui
class TestBox(QtGui.QGroupBox):
def __init__(self, parent):
QtGui.QGroupBox.__init__(self, parent)
self.setAcceptDrops(True)
self.parent = parent
self.resize(500, 500)
def dragEnterEvent(self, event):
if event.mimeData().hasFormat('text/uri-list'):
event.accept()
else:
event.ignore()
def dragMoveEvent(self, event):
if event.mimeData().hasFormat('text/uri-list'):
event.setDropAction(QtCore.Qt.CopyAction) # for nice copy icon
event.accept()
else:
event.ignore()
def dropEvent(self, event):
if event.mimeData().hasFormat('text/uri-list'):
event.setDropAction(QtCore.Qt.CopyAction) # for nice copy icon
event.acceptProposedAction()
urllist = event.mimeData().urls()
for url in urllist:
print url.toLocalFile()
else:
event.ignore()
if __name__ == '__main__':
app = QtGui.QApplication( sys.argv )
ui = QtGui.QWidget()
testBox = TestBox(ui)
ui.setWindowTitle("Test Window")
ui.show()
app.exec_()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment