annotate Mac/Tools/IDE/PythonIDE.py @ 30958:46b9fdd27ec2 legacy-trunk

Forward port of various fixes that were initially only done on the release23-maint branch: - Remember the scroll position when rebuilding the browser (as we do far too often). Fixes #824430. - Allow for the documentation to be inside PythonIDE as well as in the Python.app inside the framework (the original location for 2.3). - Updated version numbers - In PythonIDE, add the Tools/IDE directory as the second entry in sys.path in stead of as the first, leaving PythonIDE.app/Contents/Resources as the first one. - The code for setting the working directory to $HOME was both incorrect and in the wrong place, fixed. - On OSX the default location for IDE scripts is now $HOME/Library/Python/IDE-Scripts.
author Jack Jansen <jack.jansen@cwi.nl>
date Wed, 19 Nov 2003 13:45:26 +0000
parents 05da7726c027
children 0729d1db5118
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18167
c5ac6f055c62 Some long overdue maintainance. Made all IDE sources 7-bit-clean, to avoid any further encoding conversion troubles.
Just van Rossum <just@letterror.com>
parents: 11424
diff changeset
1 # copyright 1996-2001 Just van Rossum, Letterror. just@letterror.com
10047
a0b06891d286 First Checked In.
Just van Rossum <just@lettererror.com>
parents:
diff changeset
2
a0b06891d286 First Checked In.
Just van Rossum <just@lettererror.com>
parents:
diff changeset
3 # keep this (__main__) as clean as possible, since we are using
a0b06891d286 First Checked In.
Just van Rossum <just@lettererror.com>
parents:
diff changeset
4 # it like the "normal" interpreter.
a0b06891d286 First Checked In.
Just van Rossum <just@lettererror.com>
parents:
diff changeset
5
18167
c5ac6f055c62 Some long overdue maintainance. Made all IDE sources 7-bit-clean, to avoid any further encoding conversion troubles.
Just van Rossum <just@letterror.com>
parents: 11424
diff changeset
6 __version__ = '1.0.1'
21772
ec750e37671b Changes by Donovan Preston (and a few minor ones by me) to make IDE run under
Jack Jansen <jack.jansen@cwi.nl>
parents: 19515
diff changeset
7 import sys
ec750e37671b Changes by Donovan Preston (and a few minor ones by me) to make IDE run under
Jack Jansen <jack.jansen@cwi.nl>
parents: 19515
diff changeset
8 import os
10047
a0b06891d286 First Checked In.
Just van Rossum <just@lettererror.com>
parents:
diff changeset
9
a0b06891d286 First Checked In.
Just van Rossum <just@lettererror.com>
parents:
diff changeset
10 def init():
a0b06891d286 First Checked In.
Just van Rossum <just@lettererror.com>
parents:
diff changeset
11 import MacOS
21772
ec750e37671b Changes by Donovan Preston (and a few minor ones by me) to make IDE run under
Jack Jansen <jack.jansen@cwi.nl>
parents: 19515
diff changeset
12 if hasattr(MacOS, 'EnableAppswitch'):
ec750e37671b Changes by Donovan Preston (and a few minor ones by me) to make IDE run under
Jack Jansen <jack.jansen@cwi.nl>
parents: 19515
diff changeset
13 MacOS.EnableAppswitch(-1)
10047
a0b06891d286 First Checked In.
Just van Rossum <just@lettererror.com>
parents:
diff changeset
14
28941
05da7726c027 Install automatic GIL switcher upon IDE startup.
Just van Rossum <just@letterror.com>
parents: 28938
diff changeset
15 try:
05da7726c027 Install automatic GIL switcher upon IDE startup.
Just van Rossum <just@letterror.com>
parents: 28938
diff changeset
16 import autoGIL
05da7726c027 Install automatic GIL switcher upon IDE startup.
Just van Rossum <just@letterror.com>
parents: 28938
diff changeset
17 except ImportError:
05da7726c027 Install automatic GIL switcher upon IDE startup.
Just van Rossum <just@letterror.com>
parents: 28938
diff changeset
18 pass
05da7726c027 Install automatic GIL switcher upon IDE startup.
Just van Rossum <just@letterror.com>
parents: 28938
diff changeset
19 else:
05da7726c027 Install automatic GIL switcher upon IDE startup.
Just van Rossum <just@letterror.com>
parents: 28938
diff changeset
20 autoGIL.installAutoGIL()
05da7726c027 Install automatic GIL switcher upon IDE startup.
Just van Rossum <just@letterror.com>
parents: 28938
diff changeset
21
19488
42b2f1936254 Import the MacOS toolbox modules from the Carbon package.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18167
diff changeset
22 from Carbon import Qd, QuickDraw
10047
a0b06891d286 First Checked In.
Just van Rossum <just@lettererror.com>
parents:
diff changeset
23 Qd.SetCursor(Qd.GetCursor(QuickDraw.watchCursor).data)
a0b06891d286 First Checked In.
Just van Rossum <just@lettererror.com>
parents:
diff changeset
24
19515
546ef318ba5d Use the new macresource module to open the accompanying resource file (if needed).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19488
diff changeset
25 import macresource
19488
42b2f1936254 Import the MacOS toolbox modules from the Carbon package.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18167
diff changeset
26 import sys, os
19515
546ef318ba5d Use the new macresource module to open the accompanying resource file (if needed).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19488
diff changeset
27 macresource.need('DITL', 468, "PythonIDE.rsrc")
21772
ec750e37671b Changes by Donovan Preston (and a few minor ones by me) to make IDE run under
Jack Jansen <jack.jansen@cwi.nl>
parents: 19515
diff changeset
28 widgetrespathsegs = [sys.exec_prefix, "Mac", "Tools", "IDE", "Widgets.rsrc"]
ec750e37671b Changes by Donovan Preston (and a few minor ones by me) to make IDE run under
Jack Jansen <jack.jansen@cwi.nl>
parents: 19515
diff changeset
29 widgetresfile = os.path.join(*widgetrespathsegs)
26269
6b556c545ffb Another workaround, to find the IDE directory when we're in MacPython-OSX
Jack Jansen <jack.jansen@cwi.nl>
parents: 25083
diff changeset
30 if not os.path.exists(widgetresfile):
6b556c545ffb Another workaround, to find the IDE directory when we're in MacPython-OSX
Jack Jansen <jack.jansen@cwi.nl>
parents: 25083
diff changeset
31 widgetrespathsegs = [os.pardir, "Tools", "IDE", "Widgets.rsrc"]
6b556c545ffb Another workaround, to find the IDE directory when we're in MacPython-OSX
Jack Jansen <jack.jansen@cwi.nl>
parents: 25083
diff changeset
32 widgetresfile = os.path.join(*widgetrespathsegs)
19515
546ef318ba5d Use the new macresource module to open the accompanying resource file (if needed).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19488
diff changeset
33 refno = macresource.need('CURS', 468, widgetresfile)
25083
4c4f92b0af90 If there's an environment variable PYTHONIDEPATH it points to the IDE
Jack Jansen <jack.jansen@cwi.nl>
parents: 21772
diff changeset
34 if os.environ.has_key('PYTHONIDEPATH'):
4c4f92b0af90 If there's an environment variable PYTHONIDEPATH it points to the IDE
Jack Jansen <jack.jansen@cwi.nl>
parents: 21772
diff changeset
35 # For development set this environment variable
4c4f92b0af90 If there's an environment variable PYTHONIDEPATH it points to the IDE
Jack Jansen <jack.jansen@cwi.nl>
parents: 21772
diff changeset
36 ide_path = os.environ['PYTHONIDEPATH']
4c4f92b0af90 If there's an environment variable PYTHONIDEPATH it points to the IDE
Jack Jansen <jack.jansen@cwi.nl>
parents: 21772
diff changeset
37 elif refno:
19515
546ef318ba5d Use the new macresource module to open the accompanying resource file (if needed).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19488
diff changeset
38 # We're not a fullblown application
21772
ec750e37671b Changes by Donovan Preston (and a few minor ones by me) to make IDE run under
Jack Jansen <jack.jansen@cwi.nl>
parents: 19515
diff changeset
39 idepathsegs = [sys.exec_prefix, "Mac", "Tools", "IDE"]
ec750e37671b Changes by Donovan Preston (and a few minor ones by me) to make IDE run under
Jack Jansen <jack.jansen@cwi.nl>
parents: 19515
diff changeset
40 ide_path = os.path.join(*idepathsegs)
26269
6b556c545ffb Another workaround, to find the IDE directory when we're in MacPython-OSX
Jack Jansen <jack.jansen@cwi.nl>
parents: 25083
diff changeset
41 if not os.path.exists(ide_path):
6b556c545ffb Another workaround, to find the IDE directory when we're in MacPython-OSX
Jack Jansen <jack.jansen@cwi.nl>
parents: 25083
diff changeset
42 idepathsegs = [os.pardir, "Tools", "IDE"]
6b556c545ffb Another workaround, to find the IDE directory when we're in MacPython-OSX
Jack Jansen <jack.jansen@cwi.nl>
parents: 25083
diff changeset
43 for p in sys.path:
6b556c545ffb Another workaround, to find the IDE directory when we're in MacPython-OSX
Jack Jansen <jack.jansen@cwi.nl>
parents: 25083
diff changeset
44 ide_path = os.path.join(*([p]+idepathsegs))
6b556c545ffb Another workaround, to find the IDE directory when we're in MacPython-OSX
Jack Jansen <jack.jansen@cwi.nl>
parents: 25083
diff changeset
45 if os.path.exists(ide_path):
6b556c545ffb Another workaround, to find the IDE directory when we're in MacPython-OSX
Jack Jansen <jack.jansen@cwi.nl>
parents: 25083
diff changeset
46 break
6b556c545ffb Another workaround, to find the IDE directory when we're in MacPython-OSX
Jack Jansen <jack.jansen@cwi.nl>
parents: 25083
diff changeset
47
10047
a0b06891d286 First Checked In.
Just van Rossum <just@lettererror.com>
parents:
diff changeset
48 else:
19515
546ef318ba5d Use the new macresource module to open the accompanying resource file (if needed).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19488
diff changeset
49 # We are a fully frozen application
546ef318ba5d Use the new macresource module to open the accompanying resource file (if needed).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19488
diff changeset
50 ide_path = sys.argv[0]
10050
66858fdf467e Add $(APPLICATION) or :Mac:Tools:IDE at the very start of sys.path to improve startup time -- jvr
Just van Rossum <just@lettererror.com>
parents: 10049
diff changeset
51 if ide_path not in sys.path:
30958
46b9fdd27ec2 Forward port of various fixes that were initially only done on the
Jack Jansen <jack.jansen@cwi.nl>
parents: 28941
diff changeset
52 sys.path.insert(1, ide_path)
10047
a0b06891d286 First Checked In.
Just van Rossum <just@lettererror.com>
parents:
diff changeset
53
a0b06891d286 First Checked In.
Just van Rossum <just@lettererror.com>
parents:
diff changeset
54
a0b06891d286 First Checked In.
Just van Rossum <just@lettererror.com>
parents:
diff changeset
55 init()
a0b06891d286 First Checked In.
Just van Rossum <just@lettererror.com>
parents:
diff changeset
56 del init
a0b06891d286 First Checked In.
Just van Rossum <just@lettererror.com>
parents:
diff changeset
57
28938
5d4d4ebfd317 Fixed age-old beginner's error: don't start the main loop as a side
Just van Rossum <just@letterror.com>
parents: 26269
diff changeset
58 import PythonIDEMain as _PythonIDEMain
5d4d4ebfd317 Fixed age-old beginner's error: don't start the main loop as a side
Just van Rossum <just@letterror.com>
parents: 26269
diff changeset
59 _PythonIDEMain.PythonIDE()