Drag and drop files into a GUI using python and pyside

As an illustration, I've added a simple example of the python / pyside code for dragging an image file onto (a very simple) GUI. There are a number of examples on the web but I could find a simple demo of dragging and dropping files in a cross platform way.

This code includes a workaround for OSx because newer versions don't play that well with dragging and dropping in Qt4 and pyside doesn't support Qt5 (it's on the way)

Obviously a python installation, pyside and Qt4 is required. On OSx I would recommend homebrew for installing python and Qt.

To workaround the issues with dragging and dropping on OSx with Qt4, NSURL is required. For this pyobjc is required. OSx specific install:
pip install -U pyobjc-core
pip install -U pyobjc
To run:
>>> python pyside_drag_drop_file.py

1) Run the GUI

2) Click the load image button or drag and drop an image onto the GUI



Related Posts

The move towards library agnostic machine learning

Introduction to Keras Autoencoders

Live tracking of python 3 usage based on a small set of scientific libraries

Thoughts on web tools for visualisation in medical image analysis research

Packaging a python app for Ubuntu using dh-virtualenv

Interactive visualisations for research papers

Passing numpy arrays between python and c++ using cython

Jabref gtk theme

Rendering volumes on the web with x3dom