[HOWTO] Launching python from Windows Explorer

Jeffrey Kunce kuncej at mail.conservation.state.mo.us
Mon Aug 30 12:14:53 EDT 1999


I've had several requests to elaborate on an earlier post.
Perhaps someone could check this, and add to an appropriate FAQ.
These procedures are for NT, there may be minor differences for Win9x.

To easily run/open python scripts from the windows explorer,
I define several "actions" for .py files. Once these actions
are defined on a machine, you can right-click on a python script,
and choose the action you want to happen.

Action Name: test
Application: "C:\Program Files\Python\python.exe" -i "%1"
Description: Runs the python script in an MSDOS window. Leaves
the window open, and the interpreter running, when the script
finishes. Good for debugging, esp when using the pdb module.

Action Name: wordpad
Application: "C:\Program Files\Windows NT\Accessories\wordpad.exe" "%1"
Description: Opens the python script for editing in wordpad.

Action Name: idle
Application: "C:\Program Files\Python\pythonw.exe" "C:\Program Files\Python\Tools\idle\idle.pyw" "%1"
Description: Opens the python script for editing/running in Idle. Each time
this action is used, it will open a new instance of Idle. To open additional scripts, 
use Idle's File/Open command.

To define an action for a ".py" files:
  -open Windows [NT] Explorer
  -from the "View" menu, select "Options"
  -select the "File Types" tab
  -from "Registered File Types", select "Python File" 
  -click the "Edit" button
  -click the "New" button
  -for "Action", enter the action name to be 
displayed in the popup menu
  -for "Application used", enter the command 
line (as in the examples above)
  -click "OK", etc...

Variations of this process will edit existing
actions, or define actions for new file types.

  --Jeff





More information about the Python-list mailing list