By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,526 Members | 1,618 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,526 IT Pros & Developers. It's quick & easy.

(Windows) "Dropping" stuff onto a Python script

P: n/a
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
Nov 6 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
da**********@googlemail.com wrote:
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
Nov 6 '08 #2

P: n/a
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

<da**********@googlemail.comwrote in message
news:b2**********************************@a29g2000 pra.googlegroups.com...
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
--
http://mail.python.org/mailman/listinfo/python-list


Nov 7 '08 #3

P: n/a
On Nov 6, 2:56*am, daniel.ha...@googlemail.com wrote:
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>
Nov 7 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.