1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #!/usr/bin/python3 #-*- coding: utf-8 -*- import sys from PyQt5 import QtWidgets, QtGui, QtCore class MainWidget(QtWidgets.QMainWindow): def __init__(self, parent=None): super(MainWidget, self).__init__(parent) self.setWindowTitle("title") self.resize(720,480) self.setAcceptDrops(True) def dragEnterEvent(self, event): if event.mimeData().hasUrls(): event.accept() else: event.ignore() def dropEvent(self, event): files = [u.toLocalFile() for u in event.mimeData().urls()] for f in files: print(f) if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) MainWindow = MainWidget() MainWindow.show() sys.exit(app.exec_()) | cs |
'Python > PyQt5' 카테고리의 다른 글
[PyQt5, pyinstaller] pyinstaller로 PyQt5로 만들어진 앱 컴파일하기 (2) | 2017.01.18 |
---|