Mercurial > cpython-lru_cache-weakref
annotate Mac/Tools/IDE/PythonIDEMain.py @ 26346:547de407c133 legacy-trunk
workaround so the (otherwise still broken) IDE can at least quit in the Python 2.2 Jaguar addon install
| author | Just van Rossum <just@letterror.com> |
|---|---|
| date | Fri, 22 Nov 2002 12:48:47 +0000 |
| parents | 2bcb41611fae |
| children | ea5ee3e7bfb1 |
| rev | line source |
|---|---|
|
20836
c1ebc0285a5e
removed import display hackery
Just van Rossum <just@letterror.com>
parents:
19488
diff
changeset
|
1 # copyright 1997-2001 Just van Rossum, Letterror. just@letterror.com |
| 10047 | 2 |
| 3 import Splash | |
| 4 | |
| 5 import FrameWork | |
| 6 import Wapplication | |
| 7 import W | |
| 8 import os | |
|
22672
86ce9ee14045
Allow file without filetype as long as they end in ".py".
Jack Jansen <jack.jansen@cwi.nl>
parents:
21867
diff
changeset
|
9 import sys |
| 10047 | 10 import macfs |
|
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:
20836
diff
changeset
|
11 import MacOS |
| 10047 | 12 |
|
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:
20836
diff
changeset
|
13 if MacOS.runtimemodel == 'macho': |
|
ec750e37671b
Changes by Donovan Preston (and a few minor ones by me) to make IDE run under
Jack Jansen <jack.jansen@cwi.nl>
parents:
20836
diff
changeset
|
14 ELIPSES = '...' |
|
ec750e37671b
Changes by Donovan Preston (and a few minor ones by me) to make IDE run under
Jack Jansen <jack.jansen@cwi.nl>
parents:
20836
diff
changeset
|
15 else: |
|
ec750e37671b
Changes by Donovan Preston (and a few minor ones by me) to make IDE run under
Jack Jansen <jack.jansen@cwi.nl>
parents:
20836
diff
changeset
|
16 ELIPSES = '\xc9' |
| 10047 | 17 |
|
21867
da008b5c5035
Don't append quit menu when on OSX, it is special and automatic there.
Just van Rossum <just@letterror.com>
parents:
21772
diff
changeset
|
18 def runningOnOSX(): |
|
da008b5c5035
Don't append quit menu when on OSX, it is special and automatic there.
Just van Rossum <just@letterror.com>
parents:
21772
diff
changeset
|
19 from gestalt import gestalt |
|
da008b5c5035
Don't append quit menu when on OSX, it is special and automatic there.
Just van Rossum <just@letterror.com>
parents:
21772
diff
changeset
|
20 gestaltMenuMgrAquaLayoutBit = 1 # menus have the Aqua 1.0 layout |
|
da008b5c5035
Don't append quit menu when on OSX, it is special and automatic there.
Just van Rossum <just@letterror.com>
parents:
21772
diff
changeset
|
21 gestaltMenuMgrAquaLayoutMask = (1L << gestaltMenuMgrAquaLayoutBit) |
|
da008b5c5035
Don't append quit menu when on OSX, it is special and automatic there.
Just van Rossum <just@letterror.com>
parents:
21772
diff
changeset
|
22 value = gestalt("menu") & gestaltMenuMgrAquaLayoutMask |
|
da008b5c5035
Don't append quit menu when on OSX, it is special and automatic there.
Just van Rossum <just@letterror.com>
parents:
21772
diff
changeset
|
23 return not not value |
|
da008b5c5035
Don't append quit menu when on OSX, it is special and automatic there.
Just van Rossum <just@letterror.com>
parents:
21772
diff
changeset
|
24 |
|
da008b5c5035
Don't append quit menu when on OSX, it is special and automatic there.
Just van Rossum <just@letterror.com>
parents:
21772
diff
changeset
|
25 |
| 10047 | 26 class PythonIDE(Wapplication.Application): |
| 27 | |
| 28 def __init__(self): | |
|
24226
62d8f974811f
fixed wrong classic MacOS pathname assumption
Just van Rossum <just@letterror.com>
parents:
22675
diff
changeset
|
29 self.preffilepath = os.path.join("Python", "PythonIDE preferences") |
|
10322
a87cfea30b04
changed creator to 'Pide' -- jvr
Just van Rossum <just@lettererror.com>
parents:
10310
diff
changeset
|
30 Wapplication.Application.__init__(self, 'Pide') |
|
19488
42b2f1936254
Import the MacOS toolbox modules from the Carbon package.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18167
diff
changeset
|
31 from Carbon import AE |
|
42b2f1936254
Import the MacOS toolbox modules from the Carbon package.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18167
diff
changeset
|
32 from Carbon import AppleEvents |
| 10047 | 33 |
| 34 AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEOpenApplication, | |
| 35 self.ignoreevent) | |
|
17015
3c650d9c38e7
Handle the ReopenApplication event (by ignoring it).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15284
diff
changeset
|
36 AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEReopenApplication, |
|
3c650d9c38e7
Handle the ReopenApplication event (by ignoring it).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15284
diff
changeset
|
37 self.ignoreevent) |
| 10047 | 38 AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEPrintDocuments, |
| 39 self.ignoreevent) | |
| 40 AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEOpenDocuments, | |
| 41 self.opendocsevent) | |
| 42 AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEQuitApplication, | |
| 43 self.quitevent) | |
| 44 import PyConsole, PyEdit | |
| 45 Splash.wait() | |
|
25869
2bcb41611fae
cd to users home dir if no current dir has been set. Fixes bug #625734
Just van Rossum <just@letterror.com>
parents:
25224
diff
changeset
|
46 if sys.platform == "darwin": |
|
2bcb41611fae
cd to users home dir if no current dir has been set. Fixes bug #625734
Just van Rossum <just@letterror.com>
parents:
25224
diff
changeset
|
47 if sys.argv and sys.argv[0].startswith("-psn"): |
|
2bcb41611fae
cd to users home dir if no current dir has been set. Fixes bug #625734
Just van Rossum <just@letterror.com>
parents:
25224
diff
changeset
|
48 home = os.getenv("HOME") |
|
2bcb41611fae
cd to users home dir if no current dir has been set. Fixes bug #625734
Just van Rossum <just@letterror.com>
parents:
25224
diff
changeset
|
49 if home: |
|
2bcb41611fae
cd to users home dir if no current dir has been set. Fixes bug #625734
Just van Rossum <just@letterror.com>
parents:
25224
diff
changeset
|
50 os.chdir(home) |
|
22672
86ce9ee14045
Allow file without filetype as long as they end in ".py".
Jack Jansen <jack.jansen@cwi.nl>
parents:
21867
diff
changeset
|
51 # With -D option (OSX command line only) keep stderr, for debugging the IDE |
|
86ce9ee14045
Allow file without filetype as long as they end in ".py".
Jack Jansen <jack.jansen@cwi.nl>
parents:
21867
diff
changeset
|
52 # itself. |
|
86ce9ee14045
Allow file without filetype as long as they end in ".py".
Jack Jansen <jack.jansen@cwi.nl>
parents:
21867
diff
changeset
|
53 debug_stderr = None |
|
22675
57811c355f3a
repair damage: now works again as a CFM app.
Just van Rossum <just@letterror.com>
parents:
22672
diff
changeset
|
54 if len(sys.argv) >= 2 and sys.argv[1] == '-D': |
|
22672
86ce9ee14045
Allow file without filetype as long as they end in ".py".
Jack Jansen <jack.jansen@cwi.nl>
parents:
21867
diff
changeset
|
55 debug_stderr = sys.stderr |
|
86ce9ee14045
Allow file without filetype as long as they end in ".py".
Jack Jansen <jack.jansen@cwi.nl>
parents:
21867
diff
changeset
|
56 del sys.argv[1] |
| 10047 | 57 PyConsole.installoutput() |
| 58 PyConsole.installconsole() | |
|
22672
86ce9ee14045
Allow file without filetype as long as they end in ".py".
Jack Jansen <jack.jansen@cwi.nl>
parents:
21867
diff
changeset
|
59 if debug_stderr: |
|
86ce9ee14045
Allow file without filetype as long as they end in ".py".
Jack Jansen <jack.jansen@cwi.nl>
parents:
21867
diff
changeset
|
60 sys.stderr = debug_stderr |
| 10047 | 61 for path in sys.argv[1:]: |
|
26346
547de407c133
workaround so the (otherwise still broken) IDE can at least quit in the Python 2.2 Jaguar addon install
Just van Rossum <just@letterror.com>
parents:
25869
diff
changeset
|
62 if path.startswith("-p"): |
|
547de407c133
workaround so the (otherwise still broken) IDE can at least quit in the Python 2.2 Jaguar addon install
Just van Rossum <just@letterror.com>
parents:
25869
diff
changeset
|
63 # process number added by the OS |
|
547de407c133
workaround so the (otherwise still broken) IDE can at least quit in the Python 2.2 Jaguar addon install
Just van Rossum <just@letterror.com>
parents:
25869
diff
changeset
|
64 continue |
| 10047 | 65 self.opendoc(path) |
|
26346
547de407c133
workaround so the (otherwise still broken) IDE can at least quit in the Python 2.2 Jaguar addon install
Just van Rossum <just@letterror.com>
parents:
25869
diff
changeset
|
66 self.mainloop() |
| 10047 | 67 |
| 68 def makeusermenus(self): | |
| 69 m = Wapplication.Menu(self.menubar, "File") | |
| 70 newitem = FrameWork.MenuItem(m, "New", "N", 'new') | |
|
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:
20836
diff
changeset
|
71 openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open') |
| 10047 | 72 FrameWork.Separator(m) |
| 73 closeitem = FrameWork.MenuItem(m, "Close", "W", 'close') | |
| 74 saveitem = FrameWork.MenuItem(m, "Save", "S", 'save') | |
|
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:
20836
diff
changeset
|
75 saveasitem = FrameWork.MenuItem(m, "Save as"+ELIPSES, None, 'save_as') |
| 10047 | 76 FrameWork.Separator(m) |
|
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:
20836
diff
changeset
|
77 saveasappletitem = FrameWork.MenuItem(m, "Save as Applet"+ELIPSES, None, 'save_as_applet') |
|
21867
da008b5c5035
Don't append quit menu when on OSX, it is special and automatic there.
Just van Rossum <just@letterror.com>
parents:
21772
diff
changeset
|
78 if not runningOnOSX(): |
|
da008b5c5035
Don't append quit menu when on OSX, it is special and automatic there.
Just van Rossum <just@letterror.com>
parents:
21772
diff
changeset
|
79 # On OSX there's a special "magic" quit menu, so we shouldn't add |
|
da008b5c5035
Don't append quit menu when on OSX, it is special and automatic there.
Just van Rossum <just@letterror.com>
parents:
21772
diff
changeset
|
80 # it to the File menu. |
|
da008b5c5035
Don't append quit menu when on OSX, it is special and automatic there.
Just van Rossum <just@letterror.com>
parents:
21772
diff
changeset
|
81 FrameWork.Separator(m) |
|
da008b5c5035
Don't append quit menu when on OSX, it is special and automatic there.
Just van Rossum <just@letterror.com>
parents:
21772
diff
changeset
|
82 quititem = FrameWork.MenuItem(m, "Quit", "Q", 'quit') |
| 10047 | 83 |
| 84 m = Wapplication.Menu(self.menubar, "Edit") | |
| 85 undoitem = FrameWork.MenuItem(m, "Undo", 'Z', "undo") | |
| 86 FrameWork.Separator(m) | |
| 87 cutitem = FrameWork.MenuItem(m, "Cut", 'X', "cut") | |
| 88 copyitem = FrameWork.MenuItem(m, "Copy", "C", "copy") | |
| 89 pasteitem = FrameWork.MenuItem(m, "Paste", "V", "paste") | |
| 90 FrameWork.MenuItem(m, "Clear", None, "clear") | |
| 91 FrameWork.Separator(m) | |
| 92 selallitem = FrameWork.MenuItem(m, "Select all", "A", "selectall") | |
| 93 sellineitem = FrameWork.MenuItem(m, "Select line", "L", "selectline") | |
| 94 FrameWork.Separator(m) | |
|
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:
20836
diff
changeset
|
95 finditem = FrameWork.MenuItem(m, "Find"+ELIPSES, "F", "find") |
| 10047 | 96 findagainitem = FrameWork.MenuItem(m, "Find again", 'G', "findnext") |
| 97 enterselitem = FrameWork.MenuItem(m, "Enter search string", "E", "entersearchstring") | |
| 98 replaceitem = FrameWork.MenuItem(m, "Replace", None, "replace") | |
| 99 replacefinditem = FrameWork.MenuItem(m, "Replace & find again", 'T', "replacefind") | |
| 100 FrameWork.Separator(m) | |
| 101 shiftleftitem = FrameWork.MenuItem(m, "Shift left", "[", "shiftleft") | |
| 102 shiftrightitem = FrameWork.MenuItem(m, "Shift right", "]", "shiftright") | |
| 103 | |
| 104 m = Wapplication.Menu(self.menubar, "Python") | |
| 105 runitem = FrameWork.MenuItem(m, "Run window", "R", 'run') | |
| 106 runselitem = FrameWork.MenuItem(m, "Run selection", None, 'runselection') | |
| 107 FrameWork.Separator(m) | |
|
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:
20836
diff
changeset
|
108 moditem = FrameWork.MenuItem(m, "Module browser"+ELIPSES, "M", self.domenu_modulebrowser) |
| 10047 | 109 FrameWork.Separator(m) |
| 110 mm = FrameWork.SubMenu(m, "Preferences") | |
|
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:
20836
diff
changeset
|
111 FrameWork.MenuItem(mm, "Set Scripts folder"+ELIPSES, None, self.do_setscriptsfolder) |
|
ec750e37671b
Changes by Donovan Preston (and a few minor ones by me) to make IDE run under
Jack Jansen <jack.jansen@cwi.nl>
parents:
20836
diff
changeset
|
112 FrameWork.MenuItem(mm, "Editor default settings"+ELIPSES, None, self.do_editorprefs) |
|
ec750e37671b
Changes by Donovan Preston (and a few minor ones by me) to make IDE run under
Jack Jansen <jack.jansen@cwi.nl>
parents:
20836
diff
changeset
|
113 FrameWork.MenuItem(mm, "Set default window font"+ELIPSES, None, self.do_setwindowfont) |
| 10047 | 114 |
| 115 self.openwindowsmenu = Wapplication.Menu(self.menubar, 'Windows') | |
| 116 self.makeopenwindowsmenu() | |
| 117 self._menustocheck = [closeitem, saveitem, saveasitem, saveasappletitem, | |
| 118 undoitem, cutitem, copyitem, pasteitem, | |
| 119 selallitem, sellineitem, | |
| 120 finditem, findagainitem, enterselitem, replaceitem, replacefinditem, | |
| 121 shiftleftitem, shiftrightitem, | |
| 122 runitem, runselitem] | |
| 123 | |
| 124 prefs = self.getprefs() | |
| 125 try: | |
| 126 fss, fss_changed = macfs.RawAlias(prefs.scriptsfolder).Resolve() | |
|
10310
a4d99607344f
fixed "crashing" bug when scripts folder as stored in prefs file does not exist.
Just van Rossum <just@lettererror.com>
parents:
10087
diff
changeset
|
127 self.scriptsfolder = fss.NewAlias() |
| 10047 | 128 except: |
|
11325
c702a12d318d
1 - added "set default window font" menu
Just van Rossum <just@lettererror.com>
parents:
11031
diff
changeset
|
129 path = os.path.join(os.getcwd(), ":Mac:IDE scripts") |
| 10047 | 130 if not os.path.exists(path): |
|
11325
c702a12d318d
1 - added "set default window font" menu
Just van Rossum <just@lettererror.com>
parents:
11031
diff
changeset
|
131 path = os.path.join(os.getcwd(), "Scripts") |
|
c702a12d318d
1 - added "set default window font" menu
Just van Rossum <just@lettererror.com>
parents:
11031
diff
changeset
|
132 if not os.path.exists(path): |
|
c702a12d318d
1 - added "set default window font" menu
Just van Rossum <just@lettererror.com>
parents:
11031
diff
changeset
|
133 os.mkdir(path) |
|
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:
20836
diff
changeset
|
134 f = open(os.path.join(path, "Place your scripts here"+ELIPSES), "w") |
|
11325
c702a12d318d
1 - added "set default window font" menu
Just van Rossum <just@lettererror.com>
parents:
11031
diff
changeset
|
135 f.close() |
| 10047 | 136 fss = macfs.FSSpec(path) |
| 137 self.scriptsfolder = fss.NewAlias() | |
| 138 self.scriptsfoldermodtime = fss.GetDates()[1] | |
| 139 else: | |
| 140 self.scriptsfoldermodtime = fss.GetDates()[1] | |
| 141 prefs.scriptsfolder = self.scriptsfolder.data | |
| 142 self._scripts = {} | |
| 143 self.scriptsmenu = None | |
| 144 self.makescriptsmenu() | |
|
25084
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
145 self.makehelpmenu() |
| 10047 | 146 |
| 147 def quitevent(self, theAppleEvent, theReply): | |
|
19488
42b2f1936254
Import the MacOS toolbox modules from the Carbon package.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18167
diff
changeset
|
148 from Carbon import AE |
| 10047 | 149 AE.AEInteractWithUser(50000000) |
| 150 self._quit() | |
| 151 | |
| 152 def suspendresume(self, onoff): | |
| 153 if onoff: | |
| 154 fss, fss_changed = self.scriptsfolder.Resolve() | |
| 155 modtime = fss.GetDates()[1] | |
| 156 if self.scriptsfoldermodtime <> modtime or fss_changed: | |
| 157 self.scriptsfoldermodtime = modtime | |
| 158 W.SetCursor('watch') | |
| 159 self.makescriptsmenu() | |
| 160 | |
| 161 def ignoreevent(self, theAppleEvent, theReply): | |
| 162 pass | |
| 163 | |
| 164 def opendocsevent(self, theAppleEvent, theReply): | |
| 165 W.SetCursor('watch') | |
| 166 import aetools | |
| 167 parameters, args = aetools.unpackevent(theAppleEvent) | |
| 168 docs = parameters['----'] | |
| 169 if type(docs) <> type([]): | |
| 170 docs = [docs] | |
| 171 for doc in docs: | |
| 172 fss, a = doc.Resolve() | |
| 173 path = fss.as_pathname() | |
| 174 self.opendoc(path) | |
| 175 | |
| 176 def opendoc(self, path): | |
| 177 fcreator, ftype = macfs.FSSpec(path).GetCreatorType() | |
| 178 if ftype == 'TEXT': | |
| 179 self.openscript(path) | |
|
22672
86ce9ee14045
Allow file without filetype as long as they end in ".py".
Jack Jansen <jack.jansen@cwi.nl>
parents:
21867
diff
changeset
|
180 elif ftype == '\0\0\0\0' and path[-3:] == '.py': |
|
86ce9ee14045
Allow file without filetype as long as they end in ".py".
Jack Jansen <jack.jansen@cwi.nl>
parents:
21867
diff
changeset
|
181 self.openscript(path) |
| 10047 | 182 else: |
|
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:
17844
diff
changeset
|
183 W.Message("Can't open file of type '%s'." % ftype) |
| 10047 | 184 |
| 185 def getabouttext(self): | |
|
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:
20836
diff
changeset
|
186 return "About Python IDE"+ELIPSES |
| 10047 | 187 |
| 188 def do_about(self, id, item, window, event): | |
| 189 Splash.about() | |
| 190 | |
| 191 def do_setscriptsfolder(self, *args): | |
| 192 fss, ok = macfs.GetDirectory("Select Scripts Folder") | |
| 193 if ok: | |
| 194 prefs = self.getprefs() | |
| 195 alis = fss.NewAlias() | |
| 196 prefs.scriptsfolder = alis.data | |
| 197 self.scriptsfolder = alis | |
| 198 self.makescriptsmenu() | |
| 199 prefs.save() | |
| 200 | |
| 201 def domenu_modulebrowser(self, *args): | |
| 202 W.SetCursor('watch') | |
| 203 import ModuleBrowser | |
| 204 ModuleBrowser.ModuleBrowser() | |
| 205 | |
| 206 def domenu_open(self, *args): | |
| 207 fss, ok = macfs.StandardGetFile("TEXT") | |
| 208 if ok: | |
| 209 self.openscript(fss.as_pathname()) | |
| 210 | |
| 211 def domenu_new(self, *args): | |
| 212 W.SetCursor('watch') | |
| 213 import PyEdit | |
| 214 return PyEdit.Editor() | |
| 215 | |
| 216 def makescriptsmenu(self): | |
| 217 W.SetCursor('watch') | |
| 218 if self._scripts: | |
| 219 for id, item in self._scripts.keys(): | |
| 220 if self.menubar.menus.has_key(id): | |
| 221 m = self.menubar.menus[id] | |
| 222 m.delete() | |
| 223 self._scripts = {} | |
| 224 if self.scriptsmenu: | |
| 225 if hasattr(self.scriptsmenu, 'id') and self.menubar.menus.has_key(self.scriptsmenu.id): | |
| 226 self.scriptsmenu.delete() | |
| 227 self.scriptsmenu = FrameWork.Menu(self.menubar, "Scripts") | |
| 228 #FrameWork.MenuItem(self.scriptsmenu, "New script", None, self.domenu_new) | |
| 229 #self.scriptsmenu.addseparator() | |
| 230 fss, fss_changed = self.scriptsfolder.Resolve() | |
| 231 self.scriptswalk(fss.as_pathname(), self.scriptsmenu) | |
| 232 | |
| 233 def makeopenwindowsmenu(self): | |
| 234 for i in range(len(self.openwindowsmenu.items)): | |
| 235 self.openwindowsmenu.menu.DeleteMenuItem(1) | |
| 236 self.openwindowsmenu.items = [] | |
| 237 windows = [] | |
| 238 self._openwindows = {} | |
| 239 for window in self._windows.keys(): | |
| 240 title = window.GetWTitle() | |
| 241 if not title: | |
| 242 title = "<no title>" | |
|
11949
5e48d83c0fce
Fixed multi-arg appends.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11325
diff
changeset
|
243 windows.append((title, window)) |
| 10047 | 244 windows.sort() |
| 245 for title, window in windows: | |
| 246 if title == "Python Interactive": # ugly but useful hack by Joe Strout | |
| 247 shortcut = '0' | |
| 248 else: | |
| 249 shortcut = None | |
| 250 item = FrameWork.MenuItem(self.openwindowsmenu, title, shortcut, callback = self.domenu_openwindows) | |
| 251 self._openwindows[item.item] = window | |
| 252 self._openwindowscheckmark = 0 | |
| 253 self.checkopenwindowsmenu() | |
| 254 | |
| 255 def domenu_openwindows(self, id, item, window, event): | |
| 256 w = self._openwindows[item] | |
| 257 w.ShowWindow() | |
| 258 w.SelectWindow() | |
| 259 | |
| 260 def domenu_quit(self): | |
| 261 self._quit() | |
| 262 | |
| 263 def domenu_save(self, *args): | |
| 264 print "Save" | |
| 265 | |
| 266 def _quit(self): | |
| 267 import PyConsole, PyEdit | |
| 268 for window in self._windows.values(): | |
|
11031
8b7f65b0db18
mod from Joe Strout: when quitting, catch errors in window.close() methods and ignore them. Otherwise one can never quit.
Just van Rossum <just@lettererror.com>
parents:
10322
diff
changeset
|
269 try: |
|
8b7f65b0db18
mod from Joe Strout: when quitting, catch errors in window.close() methods and ignore them. Otherwise one can never quit.
Just van Rossum <just@lettererror.com>
parents:
10322
diff
changeset
|
270 rv = window.close() # ignore any errors while quitting |
|
8b7f65b0db18
mod from Joe Strout: when quitting, catch errors in window.close() methods and ignore them. Otherwise one can never quit.
Just van Rossum <just@lettererror.com>
parents:
10322
diff
changeset
|
271 except: |
|
8b7f65b0db18
mod from Joe Strout: when quitting, catch errors in window.close() methods and ignore them. Otherwise one can never quit.
Just van Rossum <just@lettererror.com>
parents:
10322
diff
changeset
|
272 rv = 0 # (otherwise, we can get stuck!) |
| 10047 | 273 if rv and rv > 0: |
| 274 return | |
|
26346
547de407c133
workaround so the (otherwise still broken) IDE can at least quit in the Python 2.2 Jaguar addon install
Just van Rossum <just@letterror.com>
parents:
25869
diff
changeset
|
275 try: |
|
547de407c133
workaround so the (otherwise still broken) IDE can at least quit in the Python 2.2 Jaguar addon install
Just van Rossum <just@letterror.com>
parents:
25869
diff
changeset
|
276 PyConsole.console.writeprefs() |
|
547de407c133
workaround so the (otherwise still broken) IDE can at least quit in the Python 2.2 Jaguar addon install
Just van Rossum <just@letterror.com>
parents:
25869
diff
changeset
|
277 PyConsole.output.writeprefs() |
|
547de407c133
workaround so the (otherwise still broken) IDE can at least quit in the Python 2.2 Jaguar addon install
Just van Rossum <just@letterror.com>
parents:
25869
diff
changeset
|
278 PyEdit.searchengine.writeprefs() |
|
547de407c133
workaround so the (otherwise still broken) IDE can at least quit in the Python 2.2 Jaguar addon install
Just van Rossum <just@letterror.com>
parents:
25869
diff
changeset
|
279 except: |
|
547de407c133
workaround so the (otherwise still broken) IDE can at least quit in the Python 2.2 Jaguar addon install
Just van Rossum <just@letterror.com>
parents:
25869
diff
changeset
|
280 # Write to __stderr__ so the msg end up in Console.app and has |
|
547de407c133
workaround so the (otherwise still broken) IDE can at least quit in the Python 2.2 Jaguar addon install
Just van Rossum <just@letterror.com>
parents:
25869
diff
changeset
|
281 # at least _some_ chance of getting read... |
|
547de407c133
workaround so the (otherwise still broken) IDE can at least quit in the Python 2.2 Jaguar addon install
Just van Rossum <just@letterror.com>
parents:
25869
diff
changeset
|
282 # But: this is a workaround for way more serious problems with |
|
547de407c133
workaround so the (otherwise still broken) IDE can at least quit in the Python 2.2 Jaguar addon install
Just van Rossum <just@letterror.com>
parents:
25869
diff
changeset
|
283 # the Python 2.2 Jaguar addon. |
|
547de407c133
workaround so the (otherwise still broken) IDE can at least quit in the Python 2.2 Jaguar addon install
Just van Rossum <just@letterror.com>
parents:
25869
diff
changeset
|
284 sys.__stderr__.write("*** PythonIDE: Can't write preferences ***\n") |
| 10047 | 285 self.quitting = 1 |
|
25084
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
286 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
287 def makehelpmenu(self): |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
288 docs = self.installdocumentation() |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
289 self.helpmenu = m = self.gethelpmenu() |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
290 docitem = FrameWork.MenuItem(m, "Python Documentation", None, self.domenu_localdocs) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
291 docitem.enable(docs) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
292 finditem = FrameWork.MenuItem(m, "Lookup in Python Documentation", None, 'lookuppython') |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
293 finditem.enable(docs) |
|
25156
bf90fb71aa76
Reorganized order of help menu, and don't show Carbon documentation
Jack Jansen <jack.jansen@cwi.nl>
parents:
25084
diff
changeset
|
294 if runningOnOSX(): |
|
bf90fb71aa76
Reorganized order of help menu, and don't show Carbon documentation
Jack Jansen <jack.jansen@cwi.nl>
parents:
25084
diff
changeset
|
295 FrameWork.Separator(m) |
|
bf90fb71aa76
Reorganized order of help menu, and don't show Carbon documentation
Jack Jansen <jack.jansen@cwi.nl>
parents:
25084
diff
changeset
|
296 doc2item = FrameWork.MenuItem(m, "Apple Developer Documentation", None, self.domenu_appledocs) |
|
bf90fb71aa76
Reorganized order of help menu, and don't show Carbon documentation
Jack Jansen <jack.jansen@cwi.nl>
parents:
25084
diff
changeset
|
297 find2item = FrameWork.MenuItem(m, "Lookup in Carbon Documentation", None, 'lookupcarbon') |
|
25084
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
298 FrameWork.Separator(m) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
299 webitem = FrameWork.MenuItem(m, "Python Documentation on the Web", None, self.domenu_webdocs) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
300 web2item = FrameWork.MenuItem(m, "Python on the Web", None, self.domenu_webpython) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
301 web3item = FrameWork.MenuItem(m, "MacPython on the Web", None, self.domenu_webmacpython) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
302 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
303 def domenu_localdocs(self, *args): |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
304 from Carbon import AH |
|
25224
e709a3c8bfec
Pass None to AHGotoPage().
Jack Jansen <jack.jansen@cwi.nl>
parents:
25156
diff
changeset
|
305 AH.AHGotoPage("Python Help", None, None) |
|
25084
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
306 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
307 def domenu_appledocs(self, *args): |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
308 from Carbon import AH, AppleHelp |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
309 try: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
310 AH.AHGotoMainTOC(AppleHelp.kAHTOCTypeDeveloper) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
311 except AH.Error, arg: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
312 if arg[0] == -50: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
313 W.Message("Developer documentation not installed") |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
314 else: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
315 W.Message("AppleHelp Error: %s" % `arg`) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
316 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
317 def domenu_lookuppython(self, *args): |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
318 from Carbon import AH |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
319 searchstring = self._getsearchstring() |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
320 if not searchstring: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
321 return |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
322 try: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
323 AH.AHSearch("Python Help", searchstring) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
324 except AH.Error, arg: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
325 W.Message("AppleHelp Error: %s" % `arg`) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
326 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
327 def domenu_lookupcarbon(self, *args): |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
328 from Carbon import AH |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
329 searchstring = self._getsearchstring() |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
330 if not searchstring: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
331 return |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
332 try: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
333 AH.AHSearch("Carbon", searchstring) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
334 except AH.Error, arg: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
335 W.Message("AppleHelp Error: %s" % `arg`) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
336 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
337 def _getsearchstring(self): |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
338 import PyEdit |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
339 editor = PyEdit.findeditor(None, fromtop=1) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
340 if editor: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
341 text = editor.getselectedtext() |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
342 if text: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
343 return text |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
344 # This is a cop-out. We should have disabled the menus |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
345 # if there is no selection, but the can_ methods only seem |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
346 # to work for Windows. Or not for the Help menu, maybe? |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
347 import EasyDialogs |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
348 text = EasyDialogs.AskString("Search documentation for", ok="Search") |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
349 return text |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
350 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
351 def domenu_webdocs(self, *args): |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
352 import webbrowser |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
353 major, minor, micro, state, nano = sys.version_info |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
354 if state in ('alpha', 'beta'): |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
355 docversion = 'dev/doc/devel' |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
356 elif micro == 0: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
357 docversion = 'doc/%d.%d' % (major, minor) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
358 else: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
359 docversion = 'doc/%d.%d.%d' % (major, minor, micro) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
360 webbrowser.open("http://www.python.org/%s" % docversion) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
361 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
362 def domenu_webpython(self, *args): |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
363 import webbrowser |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
364 webbrowser.open("http://www.python.org/") |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
365 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
366 def domenu_webmacpython(self, *args): |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
367 import webbrowser |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
368 webbrowser.open("http://www.cwi.nl/~jack/macpython.html") |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
369 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
370 def installdocumentation(self): |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
371 # This is rather much of a hack. Someone has to tell the Help Viewer |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
372 # about the Python documentation, so why not us. The documentation |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
373 # is located in the framework, but there's a symlink in Python.app. |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
374 # And as AHRegisterHelpBook wants a bundle (with the right bits in |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
375 # the plist file) we refer it to Python.app |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
376 python_app = os.path.join(sys.prefix, 'Resources/Python.app') |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
377 doc_source = os.path.join(python_app, 'Contents/Resources/English.lproj/Documentation') |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
378 if not os.path.isdir(doc_source): |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
379 return 0 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
380 try: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
381 from Carbon import AH |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
382 AH.AHRegisterHelpBook(python_app) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
383 except (ImportError, MacOS.Error), arg: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
384 W.Message("Cannot register Python documentation: %s" % `arg`) |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
385 return 0 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
386 return 1 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
387 |
| 10047 | 388 |
| 389 PythonIDE() | |
| 390 |
