(Windows) "Dropping" stuff onto a Python script

D

daniel.haude

Hello people,

I'd like to have the functionality known from "real" executables that
if I drag-drop a file icon on top of the app, the app starts and has
the file's path as command-line argument.

However, this doesn't seem to work with Python scripts because Windows
sees those just as files, not apps.

Can this be done?

Thanks,

robert
 
T

Tim Golden

Hello people,

I'd like to have the functionality known from "real" executables that
if I drag-drop a file icon on top of the app, the app starts and has
the file's path as command-line argument.

However, this doesn't seem to work with Python scripts because Windows
sees those just as files, not apps.

Can this be done?

There may be fancier ways but...

.... prefix the shortcut target with the python executable:

c:\python25\python.exe myscript.py

I've just tested this with a script which does this:

<code>
import os, sys

os.startfile (sys.argv[1])

</code>

and it works ok.

TJG
 
R

Roger Upole

This is done via a drop handler.
Add registry key

HKCR\Python.File\shellex\DropHandler

with a default value of

{86C86720-42A0-1069-A2E8-08002B30309D}

Roger
 
A

Aaron Brady

Hello people,

I'd like to have the functionality known from "real" executables that
if I drag-drop a file icon on top of the app, the app starts and has
the file's path as command-line argument.

However, this doesn't seem to work with Python scripts because Windows
sees those just as files, not apps.

Can this be done?

Thanks,

robert

Did someone say dropping stuff? My favorite. Discussions, names,
babies, you get the picture.

I'll take things you drop for $500, Alex.

</humor>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top