import sys from PyQt5.QtWidgets import QApplication, QFrame app = QApplication([]) frame = QFrame() frame.setAcceptDrops(True) def f(event): print('hey') frame.dragEnterEvent = f sys.exit(app.exec_())