On 2009-08-10 22:40:14 -0400, Dave Angel <da...@ieee.org> said:

bob gailer wrote:
<div class="moz-text-flowed" style="font-family: -moz-fixed">Alan
Gauld wrote:
"pedro" <pedrooconn...@gmail.com> wrote
Well I made a script called droplet.py which looks like this:

#!/usr/bin/env python
# encoding: utf-8
import sys
theFilePath = sys.argv[1]
print theFilePath


But when I try to drop something on it nothing happens. Sorry I
guess there is something fundamental that I am missing.

Sorry, obviously I was wrong. FWIW in XP I get python to start up but
there is no filename in argv.

That depends on the file association settings for .py.
Start -> Settings -> Control Panel -> Folder Options -> File Types
Find py extension.
Click Advanced
Choose open
Click Edit
in my system I see "H:\Python30\python.exe" "%1" %*
which means fire up python.exe, pass the dropped file name as the
first argument.

BTW a nice 1 python line version independent droplet:
#!/usr/bin/env python
# encoding: utf-8
input(__import__('sys').argv)


Unfortunately, you're not describing a droplet, but only the usual
Windows file association scheme.  (Incidentally, the OP was asking about
the Mac)

The filename that goes into the %1 of the shortcut is the name of the
script.  So that will show up in sys.argv[0].  The OP wanted to drop a
data file, and have its name show up as sys.argv[1].

I don't know the Mac, so I stayed out of this thread.  But I haven't
found any way to do real Python droplets on Windows.  Closest I found
was adding my python app to the right-click menu, so one can right-click
on a data file to get the Python code to run on it.

What a droplet needs is for the user to be able to drag a data file to a
python script, and have the script start, with sys.argv[1] pointing to
the data file.   I'd love to know how to do it in Windows, and the OP
would love to know how to do it on the Mac.

DaveA

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Exactly, thanks for clarifying Dave.
Pete


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to