How to drag and drop on (python) script on OS X?

Is there a way to configure the latest OS X system so that python scripts automatically perform drag and drop functions? If not, what is the easiest way (perfect for scripting) to configure individual scripts for this behavior?

On Windows, I can simply drag and drop files onto a python script, and the python process will sys.argv with the sys.argv path names of the discarded arguments available in sys.argv . Surprisingly, this does not happen in OS X, but there seems to be no way to configure the system for this automatically. All the solutions I came across include porting each of my scripts to the application.

Of course, this question was asked and answered earlier. But I can find not only one single answer that could be included to enable drag and drop for one script at a time (by adding an application around them); it seems that all answers are outdated and / or dependent on broken links. Here's the sampler:

As already mentioned, none of them seem to work anymore. I have OS X 10.8, Mountain Lion, and I saw zilch, from which you could expect later versions of the OS. Any modern solutions?

PS: Conceptually, this question is not necessarily limited to python: I am sure that any mechanism that will work with shell or perl scripts will also work with python. But considering how complicated this sounds like OS X, I keep this question specific since my use case, and all the solutions I saw seem to be linguistic.

+5
source share
1 answer

Have you seen this answer ? Try using Mac OS X Automator (available in current and previous versions of the OS - just tested it in Yosemite). Regarding "one at a time" and "several," this SuperUser post on the same subject explains how to make it work for multiple files.

At the end of the day, โ€œDrag and Drop Supportโ€ is a functionality of the Windowing System and has nothing to do with Python. However, you can create OS X GUI applications in Python, which may be another solution for this. Check out this link about Python GUI applications for more information.

+3
source

All Articles