FAQ
I am trying to make a a simple databasing GUI interface and and have
created a module to deal with parsing the data from a file and a GUI
based program that displays this data using PyQt4, i know how to
register files in the system registry using python and also using Inno
Setup which i use to package my applications, but i cant work out how
if a file is doubled clicked on to send the path of that file to
python.

I have looked into passing command line arguments to python and can
send a specific pathname to python but ideally what i need is a
generic command that i can write to the registry that passes the
pathname of whichever file was doubled clicked!?!

am i asking too much/does it exist/is there an easier way to do this!!

CC

Search Discussions

  • Mike Driscoll at Apr 24, 2008 at 5:41 pm

    On Apr 24, 10:14?am, flarefi... at googlemail.com wrote:
    I am trying to make a a simple databasing GUI interface and and have
    created a module to deal with parsing the data from a file and a GUI
    based program that displays this data using PyQt4, i know how to
    register files in the system registry using python and also using Inno
    Setup which i use to package my applications, but i cant work out how
    if a file is doubled clicked on to send the path of that file to
    python.

    I have looked into passing command line arguments to python and can
    send a specific pathname to python but ideally what i need is a
    generic command that i can write to the registry that passes the
    pathname of whichever file was doubled clicked!?!

    am i asking too much/does it exist/is there an easier way to do this!!

    CC
    I did this by writing the path to me script or exe and added %1 to the
    end, which basically means that my program can (or requires) a
    parameter passed to it. Here's an example:

    "C:\Program Files\PyMail\wxsendmail.exe" %1

    That should work. Tested on Windows XP SP2 with Python 2.4/2.5.

    Mike
  • Flarefight at Apr 26, 2008 at 12:26 pm
    I can't get this to work (I am on XP SP2 by the way and using Python
    2.5),

    I wrote a very simple script to test the idea:

    import sys

    for arg in sys.argv:
    print arg

    raw_input("Done") #Merely to slow the program down so i can see output

    and then setup a file extension .xyz, placed it in the registry, can
    get a .xyz file to work as a python script so the registry setup is
    fine, but when i try and put the parameter to the above program and a
    %1 (or even without) it gets the following error message from windows:

    C:\...\hmm.xyz is not a valid Win32 application.

    any suggestions??
  • Lie at Apr 27, 2008 at 12:38 pm

    On Apr 24, 10:14 pm, flarefi... at googlemail.com wrote:
    I am trying to make a a simple databasing GUI interface and and have
    created a module to deal with parsing the data from a file and a GUI
    based program that displays this data using PyQt4, i know how to
    register files in the system registry using python and also using Inno
    Setup which i use to package my applications, but i cant work out how
    if a file is doubled clicked on to send the path of that file to
    python.
    Do you mean: when a file with "your extension" is double clicked on,
    then Windows should pass the path of that file to "your application"
    that is written in Python?

    (snip)
    On Apr 26, 7:26 pm, flarefi... at googlemail.com wrote:
    I can't get this to work (I am on XP SP2 by the way and using Python
    2.5),

    I wrote a very simple script to test the idea:

    import sys

    for arg in sys.argv:
    print arg

    raw_input("Done") #Merely to slow the program down so i can see output

    and then setup a file extension .xyz, placed it in the registry, can
    get a .xyz file to work as a python script so the registry setup is
    fine, but when i try and put the parameter to the above program and a
    %1 (or even without) it gets the following error message from windows:

    C:\...\hmm.xyz is not a valid Win32 application.

    any suggestions??
    Windows seems to be trying to execute your file.xyz as an application,
    this means it hasn't associated your extension (.xyz) with your
    application, instead .xyz is associated as an executable.

    To associate your extension with your application, see:
    http://msdn2.microsoft.com/en-us/library/bb776883.aspx
    It's a bit advanced

    NOT TESTED:
    # Create or edit Registry Key: 'HKEY_CLASSES_ROOT\.xyz'
    # Change the value for the key 'HKEY_CLASSES_ROOT\.xyz:' into 'MyApp'
    # Create or edit Registry Key: 'HKEY_CLASSES_ROOT\MyApp\Shell\Open
    \Command'
    # Change Registry Key value for 'HKEY_CLASSES_ROOT\MyApp\Shell\Open
    \Command' into: '"C:\pathtomyapp\myapp.py" "%1"'

    Check an existing registry key, how they do it.
  • Flarefight at Apr 27, 2008 at 1:21 pm
    Yep, thats pretty much exactly what i had done, those exact settings,
    and it still doesnt work. As i said i looked at the other keys to
    check i had done it right and a i said the settings are fine because i
    can send the file to python.exe and it loads like a python file fine,
    but it doesn't like passing it to my program. Have i done something
    wrong with my program that simply prints the arguments??
  • Lie at Apr 27, 2008 at 6:23 pm

    On Apr 27, 8:21?pm, flarefi... at googlemail.com wrote:
    Yep, thats pretty much exactly what i had done, those exact settings,
    and it still doesnt work. As i said i looked at the other keys to
    check i had done it right and a i said the settings are fine because i
    can send the file to python.exe and it loads like a python file fine,
    but it doesn't like passing it to my program. Have i done something
    wrong with my program that simply prints the arguments??
    I think either I have misunderstood the situation, you misunderstood
    your own situation, or you have expressed your situation incorrectly:
    "it loads like a python file fine". What loads like a python file
    fine? The python source or the data.xyz?

    What did you put in data.xyz? Data to be fed to your python program or
    python source code?

    Aren't we trying to load the data.xyz to your python program? Or are
    we trying to load data.xyz to python interpreter?


    Anyway, try adding quotes around the "%1", to ensure that path that
    contains spaces doesn't confuse the program
    HKEY_CLASSES_ROOT\MyApp\Shell\Open\Command => "C:\pathtomyapp
    \myapp.py" "%1"
  • Flarefight at Apr 27, 2008 at 10:13 pm
    No you didnt misunderstand the situation, i think i have confused
    matters though!! When Ive got it working my program will read the data
    within the file. But obviously for it to do that it needs to know
    where the file is, hence the whole discussion. However to test things
    were working, just with regards the setting up of the registry, and
    since the contents of the file are essentially irrelevant for the
    test, i made the test file a valid python file so that i could test
    the registry setup by sending it to python.exe. It doesnt need to be
    and wont be a python file, ultimately it will contain some cPickle
    data which the program reads from the file. But as i said i need it to
    know the path of the file it needs to unpickle.

    And there are already "" around my %1 sign. It currently reads "C:\test
    \test.py" "%1", where test.py is the short program that simply reads
    the sys.argv that i posted further up.
  • Gabriel Genellina at Apr 28, 2008 at 6:09 am

    En Sun, 27 Apr 2008 19:13:06 -0300, <flarefight at googlemail.com> escribi?:

    No you didnt misunderstand the situation, i think i have confused
    matters though!! When Ive got it working my program will read the data
    within the file. But obviously for it to do that it needs to know
    where the file is, hence the whole discussion. However to test things
    After reading the thread I'm confused as well.
    Try using an installer (like InnoSetup) to install your application. It can handle the .xyz registry stuff for you, among other things.


    --
    Gabriel Genellina

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedApr 24, '08 at 3:14p
activeApr 28, '08 at 6:09a
posts8
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase