tags:

views:

458

answers:

4

I have a python script which I can run from pythonwin on which I give the arguments. Is it possible to automate this so that when I just click on the *.py file, I don't see the script and it asks for the path in a dos window?

+2  A: 

Rename it to *.pyw to hide the console on execution in Windows.

Mark Rushakoff
I rename it to pyw but when i double click it nothing happens. And the file shows Python File(no console).
Do you actually have a proper installation of Python? It should have automatically associated .py,.pyw with C:\PythonXX\Python.exe when you installed.
Mark Rushakoff
I have PythonWin Installed which includes everything. I tried the pyw too. It just creates the file but when i double click it nothing happens
+2  A: 

You can also wrap it in a batch file, containing:

c:\path to python.exe c:\path to file.py

You can then also easily set an icon, run in window/run hidden etc on the batch file.

Martin Beckett
didn't work...i created a batch file. I guess thats created giving the paths in a txt file and renaming it as *.bat
Yes a batch file is just a text file with .bat What doesn't work ? What if you run the batch file form the command prompt?
Martin Beckett
ya it works in command prompt...but this time it gives a type error for 2 arguments...i give these arguments(i.e. paths ) when i run it from the PythonWin
+2  A: 

You're running on Windows, so you need an association between .py files and some binary to run them. Have a look at this post.

When you run "assoc .py", do you get Python.File? When you run "ftype Python.File", what do you get? If "ftype Python.File" points at some python.exe, your python script should run without any prompting.

hughdbrown
+1  A: 

how does your script ask for or get its parameters? If it expects them from the call to the script (i.e. in sys.argv) and Pythonwin just notices that and prompts you for them (I think Pyscripter does something similar) you can either run it from a CMD window (commandline) where you can give the arguments as in

python myscript.py argument-1 argument-2

or modify your script to ask for the arguments itself instead (using a gui like Tkinter if you don't want to run from commandline).

Albert Visser