Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pyqt drag and drop files

# Python 3
from PyQt5.QtWidgets import QMainWindow, QApplication
import sys

class MainWidget(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Drag and Drop")
        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 = QApplication(sys.argv)
    ui = MainWidget()
    ui.show()
    sys.exit(app.exec_())
Comment

PREVIOUS NEXT
Code Example
Python :: python delete none from list 
Python :: python setter getter deleter 
Python :: PackagesNotFoundError: The following packages are not available from current channels: - python==3.6 
Python :: how to check if left mousebuttondown in pygame 
Python :: convert negative to zero in list in python 
Python :: python regex count matches 
Python :: python 3 pm2 
Python :: find rows not equal to nan pandas 
Python :: difference between w+ and r+ in python 
Python :: how to set the screen brightness using python 
Python :: PANDAS BIGGER PLOTS 
Python :: python schedule timezone 
Python :: pandas filter string contain 
Python :: get last column pandas 
Python :: python border 
Python :: pandas row starts with 
Python :: sorting rows and columns in pandas 
Python :: python discord bot join voice channel 
Python :: python capitalize each word 
Python :: install python glob module in windows 
Python :: tk table python 
Python :: python get user home directory 
Python :: desktop background change with python 
Python :: how to plot kmeans graph 
Python :: count none in list python 
Python :: discord.py unmute 
Python :: --disable warning pytest 
Python :: sklearn roc curve 
Python :: python install required packages 
Python :: how to get the contents of a txt file in python 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =