Tony Lownds | 1fc1fe8 | 2002-12-23 18:36:14 +0000 | [diff] [blame] | 1 | #!/usr/bin/env pythonw |
Tony Lownds | cf94ee8 | 2002-12-31 18:22:37 +0000 | [diff] [blame] | 2 | # IDLE.app |
| 3 | # |
| 4 | # Installation: |
| 5 | # see the install_IDLE target in python/dist/src/Mac/OSX/Makefile |
| 6 | # |
| 7 | # Usage: |
| 8 | # |
| 9 | # 1. Double clicking IDLE icon will open IDLE. |
| 10 | # 2. Dropping file on IDLE icon will open that file in IDLE. |
| 11 | # 3. Launch from command line with files with this command-line: |
| 12 | # |
| 13 | # /Applications/Python/IDLE.app/Contents/MacOS/python file1 file2 file3 |
| 14 | # |
| 15 | # |
Tony Lownds | f53dec2 | 2002-12-20 04:24:43 +0000 | [diff] [blame] | 16 | |
| 17 | # Add IDLE.app/Contents/Resources/idlelib to path. |
| 18 | # __file__ refers to this file when it is used as a module, sys.argv[0] |
| 19 | # refers to this file when it is used as a script (pythonw macosx_main.py) |
| 20 | import sys |
| 21 | |
| 22 | from os.path import split, join, isdir |
| 23 | try: |
| 24 | __file__ |
| 25 | except NameError: |
| 26 | __file__ = sys.argv[0] |
| 27 | idlelib = join(split(__file__)[0], 'idlelib') |
| 28 | if isdir(idlelib): |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 29 | sys.path.append(idlelib) |
Tony Lownds | f53dec2 | 2002-12-20 04:24:43 +0000 | [diff] [blame] | 30 | |
Tony Lownds | f53dec2 | 2002-12-20 04:24:43 +0000 | [diff] [blame] | 31 | # see if we are being asked to execute the subprocess code |
| 32 | if '-p' in sys.argv: |
| 33 | # run expects only the port number in sys.argv |
| 34 | sys.argv.remove('-p') |
| 35 | |
Tony Lownds | 103ee91 | 2002-12-23 18:11:28 +0000 | [diff] [blame] | 36 | # this module will become the namespace used by the interactive |
Tony Lownds | f53dec2 | 2002-12-20 04:24:43 +0000 | [diff] [blame] | 37 | # interpreter; remove all variables we have defined. |
Tony Lownds | d8a6c5f | 2002-12-31 16:52:44 +0000 | [diff] [blame] | 38 | del sys, __file__, split, join, isdir, idlelib |
Tony Lownds | f53dec2 | 2002-12-20 04:24:43 +0000 | [diff] [blame] | 39 | __import__('run').main() |
| 40 | else: |
| 41 | # Load idlelib/idle.py which starts the application. |
Tony Lownds | 103ee91 | 2002-12-23 18:11:28 +0000 | [diff] [blame] | 42 | import idle |