1.2.2.1 Drag and drop

Python PEP

1.2.2.1 Drag and drop

One of the easiest ways to launch a Python script is via ``Drag and Drop''. This is just like launching a text file in the Finder by ``dragging'' it over your word processor's icon and ``dropping'' it there. Make sure that you use an icon referring to the PythonInterpreter, not the IDE or Idle icons which have different behaviour which is described below.

Some things that might have gone wrong:

  • A window flashes after dropping the script onto the PythonInterpreter, but then disappears. Most likely this is a configuration issue; your PythonInterpreter is setup to exit immediately upon completion, but your script assumes that if it prints something that text will stick around for a while. To fix this, see section 1.2.5.

  • When you waved the script icon over the PythonInterpreter, the PythonInterpreter icon did not hilight. Most likely the Creator code and document type is unset (or set incorrectly) - this often happens when a file originates on a non-Mac computer. See section 1.2.2 for more details.

See About this document... for information on suggesting changes.