(Windows) "Dropping" stuff onto a Python script

Discussion in 'Python' started by daniel.haude@googlemail.com, Nov 6, 2008.

  1. Guest

    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, 2008
    #1
    1. Advertising

  2. Tim Golden Guest

    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
    Tim Golden, Nov 6, 2008
    #2
    1. Advertising

  3. Roger Upole Guest

    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



    <> wrote in message
    news:...
    > 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
    >
    Roger Upole, Nov 7, 2008
    #3
  4. Aaron Brady Guest

    On Nov 6, 2:56 am, 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>
    Aaron Brady, Nov 7, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben
    Replies:
    2
    Views:
    2,412
    Fredrik Lundh
    Dec 5, 2006
  2. David Härdeman

    Dropping privileges in python daemon

    David Härdeman, Aug 18, 2008, in forum: Python
    Replies:
    1
    Views:
    394
    Matthias Bläsing
    Aug 18, 2008
  3. Jessica Hart
    Replies:
    0
    Views:
    84
    Jessica Hart
    Oct 1, 2003
  4. Angus

    Latching onto open web windows

    Angus, Mar 6, 2007, in forum: Javascript
    Replies:
    1
    Views:
    79
    OmegaJunior
    Mar 11, 2007
  5. Replies:
    0
    Views:
    132
Loading...

Share This Page