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

Alessandro Bottoni alessandro.bottoni at infinito.it
Mon Aug 22 03:57:43 EDT 2005


knutsample at gmail.com wrote:

> 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

-----------------------------------
Alessandro Bottoni



More information about the Python-list mailing list