win32 - associate .pyw with a file extension...

K

knutsample

Hello!

I'm trying to associate a file extension to my wxPython script so that
all I have to do is double click on the file and my python script will
load up with the path of that file.

For instance, I've associated all .py files to be opened up with
emacs.exe. If I double click on a .py file, emacs.exe would open up
with that file in its buffer.

Is there a way to do this with a non-exe (wxPython script)? Everytime
I try to associate a certain file extension (right clicking file->Open
with->Choose program) with my python script (.pyw) windows states that
I do not have a valid win32 program. Is there a way to do this with a
python script? Thank you for your time.
 
A

Alessandro Bottoni

Hello!

I'm trying to associate a file extension to my wxPython script so that
all I have to do is double click on the file and my python script will
load up with the path of that file.

For instance, I've associated all .py files to be opened up with
emacs.exe. If I double click on a .py file, emacs.exe would open up
with that file in its buffer.

Is there a way to do this with a non-exe (wxPython script)? Everytime
I try to associate a certain file extension (right clicking file->Open
with->Choose program) with my python script (.pyw) windows states that
I do not have a valid win32 program. Is there a way to do this with a
python script? Thank you for your time.


As long as I can see, you are trying to associate your .pyw extension
directly with your python script, let say "MyProgram.pyw". This cannot work
because Windows does not know how to run MyProgram.pyw itself. You have to
associate the .pyw extension with the python interpreter. The name of your
script has to be passed to python on the command line (together with its
command line parameter). That is, Windows has to be requested to executed
this command line:

c:/.../python_directory/python.exe MyProgram.pyw FirstParam SecondParam

Most likely, you are trying to execute this, instead:

c:/.../MyPrograDir/MyProgram.pyw FirstParam SecondParam

HTH
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top