Mercurial > cpython-lru_cache-weakref
annotate Mac/Tools/IDE/PythonIDEMain.py @ 27408:ea5ee3e7bfb1 legacy-trunk
Use new file dialogs.
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Sun, 26 Jan 2003 22:15:48 +0000 |
| parents | 547de407c133 |
| children | 43143d4dd6b1 |
| 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 |
| 27408 | 12 import EasyDialogs |
| 10047 | 13 |
|
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
|
14 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
|
15 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
|
16 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
|
17 ELIPSES = '\xc9' |
| 10047 | 18 |
|
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
|
19 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
|
20 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
|
21 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
|
22 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
|
23 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
|
24 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
|
25 |
|
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
|
26 |
| 10047 | 27 class PythonIDE(Wapplication.Application): |
| 28 | |
| 29 def __init__(self): | |
|
24226
62d8f974811f
fixed wrong classic MacOS pathname assumption
Just van Rossum <just@letterror.com>
parents:
22675
diff
changeset
|
30 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
|
31 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
|
32 from Carbon import AE |
|
42b2f1936254
Import the MacOS toolbox modules from the Carbon package.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18167
diff
changeset
|
33 from Carbon import AppleEvents |
| 10047 | 34 |
| 35 AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEOpenApplication, | |
| 36 self.ignoreevent) | |
|
17015
3c650d9c38e7
Handle the ReopenApplication event (by ignoring it).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15284
diff
changeset
|
37 AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEReopenApplication, |
|
3c650d9c38e7
Handle the ReopenApplication event (by ignoring it).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15284
diff
changeset
|
38 self.ignoreevent) |
| 10047 | 39 AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEPrintDocuments, |
| 40 self.ignoreevent) | |
| 41 AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEOpenDocuments, | |
| 42 self.opendocsevent) | |
| 43 AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEQuitApplication, | |
| 44 self.quitevent) | |
| 45 import PyConsole, PyEdit | |
| 46 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
|
47 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
|
48 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
|
49 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
|
50 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
|
51 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
|
52 # 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
|
53 # itself. |
|
86ce9ee14045
Allow file without filetype as long as they end in ".py".
Jack Jansen <jack.jansen@cwi.nl>
parents:
21867
diff
changeset
|
54 debug_stderr = None |
|
22675
57811c355f3a
repair damage: now works again as a CFM app.
Just van Rossum <just@letterror.com>
parents:
22672
diff
changeset
|
55 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
|
56 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
|
57 del sys.argv[1] |
| 10047 | 58 PyConsole.installoutput() |
| 59 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
|
60 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
|
61 sys.stderr = debug_stderr |
| 10047 | 62 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
|
63 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
|
64 # 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
|
65 continue |
| 10047 | 66 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
|
67 self.mainloop() |
| 10047 | 68 |
| 69 def makeusermenus(self): | |
| 70 m = Wapplication.Menu(self.menubar, "File") | |
| 71 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
|
72 openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open') |
| 10047 | 73 FrameWork.Separator(m) |
| 74 closeitem = FrameWork.MenuItem(m, "Close", "W", 'close') | |
| 75 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
|
76 saveasitem = FrameWork.MenuItem(m, "Save as"+ELIPSES, None, 'save_as') |
| 10047 | 77 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
|
78 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
|
79 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
|
80 # 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
|
81 # 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
|
82 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
|
83 quititem = FrameWork.MenuItem(m, "Quit", "Q", 'quit') |
| 10047 | 84 |
| 85 m = Wapplication.Menu(self.menubar, "Edit") | |
| 86 undoitem = FrameWork.MenuItem(m, "Undo", 'Z', "undo") | |
| 87 FrameWork.Separator(m) | |
| 88 cutitem = FrameWork.MenuItem(m, "Cut", 'X', "cut") | |
| 89 copyitem = FrameWork.MenuItem(m, "Copy", "C", "copy") | |
| 90 pasteitem = FrameWork.MenuItem(m, "Paste", "V", "paste") | |
| 91 FrameWork.MenuItem(m, "Clear", None, "clear") | |
| 92 FrameWork.Separator(m) | |
| 93 selallitem = FrameWork.MenuItem(m, "Select all", "A", "selectall") | |
| 94 sellineitem = FrameWork.MenuItem(m, "Select line", "L", "selectline") | |
| 95 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
|
96 finditem = FrameWork.MenuItem(m, "Find"+ELIPSES, "F", "find") |
| 10047 | 97 findagainitem = FrameWork.MenuItem(m, "Find again", 'G', "findnext") |
| 98 enterselitem = FrameWork.MenuItem(m, "Enter search string", "E", "entersearchstring") | |
| 99 replaceitem = FrameWork.MenuItem(m, "Replace", None, "replace") | |
| 100 replacefinditem = FrameWork.MenuItem(m, "Replace & find again", 'T', "replacefind") | |
| 101 FrameWork.Separator(m) | |
| 102 shiftleftitem = FrameWork.MenuItem(m, "Shift left", "[", "shiftleft") | |
| 103 shiftrightitem = FrameWork.MenuItem(m, "Shift right", "]", "shiftright") | |
| 104 | |
| 105 m = Wapplication.Menu(self.menubar, "Python") | |
| 106 runitem = FrameWork.MenuItem(m, "Run window", "R", 'run') | |
| 107 runselitem = FrameWork.MenuItem(m, "Run selection", None, 'runselection') | |
| 108 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
|
109 moditem = FrameWork.MenuItem(m, "Module browser"+ELIPSES, "M", self.domenu_modulebrowser) |
| 10047 | 110 FrameWork.Separator(m) |
| 111 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
|
112 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
|
113 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
|
114 FrameWork.MenuItem(mm, "Set default window font"+ELIPSES, None, self.do_setwindowfont) |
| 10047 | 115 |
| 116 self.openwindowsmenu = Wapplication.Menu(self.menubar, 'Windows') | |
| 117 self.makeopenwindowsmenu() | |
| 118 self._menustocheck = [closeitem, saveitem, saveasitem, saveasappletitem, | |
| 119 undoitem, cutitem, copyitem, pasteitem, | |
| 120 selallitem, sellineitem, | |
| 121 finditem, findagainitem, enterselitem, replaceitem, replacefinditem, | |
| 122 shiftleftitem, shiftrightitem, | |
| 123 runitem, runselitem] | |
| 124 | |
| 125 prefs = self.getprefs() | |
| 126 try: | |
| 127 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
|
128 self.scriptsfolder = fss.NewAlias() |
| 10047 | 129 except: |
|
11325
c702a12d318d
1 - added "set default window font" menu
Just van Rossum <just@lettererror.com>
parents:
11031
diff
changeset
|
130 path = os.path.join(os.getcwd(), ":Mac:IDE scripts") |
| 10047 | 131 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
|
132 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
|
133 if not os.path.exists(path): |
|
c702a12d318d
1 - added "set default window font" menu
Just van Rossum <just@lettererror.com>
parents:
11031
diff
changeset
|
134 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
|
135 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
|
136 f.close() |
| 10047 | 137 fss = macfs.FSSpec(path) |
| 138 self.scriptsfolder = fss.NewAlias() | |
| 139 self.scriptsfoldermodtime = fss.GetDates()[1] | |
| 140 else: | |
| 141 self.scriptsfoldermodtime = fss.GetDates()[1] | |
| 142 prefs.scriptsfolder = self.scriptsfolder.data | |
| 143 self._scripts = {} | |
| 144 self.scriptsmenu = None | |
| 145 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
|
146 self.makehelpmenu() |
| 10047 | 147 |
| 148 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
|
149 from Carbon import AE |
| 10047 | 150 AE.AEInteractWithUser(50000000) |
| 151 self._quit() | |
| 152 | |
| 153 def suspendresume(self, onoff): | |
| 154 if onoff: | |
| 155 fss, fss_changed = self.scriptsfolder.Resolve() | |
| 156 modtime = fss.GetDates()[1] | |
| 157 if self.scriptsfoldermodtime <> modtime or fss_changed: | |
| 158 self.scriptsfoldermodtime = modtime | |
| 159 W.SetCursor('watch') | |
| 160 self.makescriptsmenu() | |
| 161 | |
| 162 def ignoreevent(self, theAppleEvent, theReply): | |
| 163 pass | |
| 164 | |
| 165 def opendocsevent(self, theAppleEvent, theReply): | |
| 166 W.SetCursor('watch') | |
| 167 import aetools | |
| 168 parameters, args = aetools.unpackevent(theAppleEvent) | |
| 169 docs = parameters['----'] | |
| 170 if type(docs) <> type([]): | |
| 171 docs = [docs] | |
| 172 for doc in docs: | |
| 173 fss, a = doc.Resolve() | |
| 174 path = fss.as_pathname() | |
| 175 self.opendoc(path) | |
| 176 | |
| 177 def opendoc(self, path): | |
| 178 fcreator, ftype = macfs.FSSpec(path).GetCreatorType() | |
| 179 if ftype == 'TEXT': | |
| 180 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
|
181 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
|
182 self.openscript(path) |
| 10047 | 183 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
|
184 W.Message("Can't open file of type '%s'." % ftype) |
| 10047 | 185 |
| 186 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
|
187 return "About Python IDE"+ELIPSES |
| 10047 | 188 |
| 189 def do_about(self, id, item, window, event): | |
| 190 Splash.about() | |
| 191 | |
| 192 def do_setscriptsfolder(self, *args): | |
| 27408 | 193 fss = EasyDialogs.AskFolder(message="Select Scripts Folder", |
| 194 wanted=macfs.FSSpec) | |
| 195 if fss: | |
| 10047 | 196 prefs = self.getprefs() |
| 197 alis = fss.NewAlias() | |
| 198 prefs.scriptsfolder = alis.data | |
| 199 self.scriptsfolder = alis | |
| 200 self.makescriptsmenu() | |
| 201 prefs.save() | |
| 202 | |
| 203 def domenu_modulebrowser(self, *args): | |
| 204 W.SetCursor('watch') | |
| 205 import ModuleBrowser | |
| 206 ModuleBrowser.ModuleBrowser() | |
| 207 | |
| 208 def domenu_open(self, *args): | |
| 27408 | 209 filename = EasyDialogs.AskFileForOpen(typeList=("TEXT",)) |
| 210 if filename: | |
| 211 self.openscript(filename) | |
| 10047 | 212 |
| 213 def domenu_new(self, *args): | |
| 214 W.SetCursor('watch') | |
| 215 import PyEdit | |
| 216 return PyEdit.Editor() | |
| 217 | |
| 218 def makescriptsmenu(self): | |
| 219 W.SetCursor('watch') | |
| 220 if self._scripts: | |
| 221 for id, item in self._scripts.keys(): | |
| 222 if self.menubar.menus.has_key(id): | |
| 223 m = self.menubar.menus[id] | |
| 224 m.delete() | |
| 225 self._scripts = {} | |
| 226 if self.scriptsmenu: | |
| 227 if hasattr(self.scriptsmenu, 'id') and self.menubar.menus.has_key(self.scriptsmenu.id): | |
| 228 self.scriptsmenu.delete() | |
| 229 self.scriptsmenu = FrameWork.Menu(self.menubar, "Scripts") | |
| 230 #FrameWork.MenuItem(self.scriptsmenu, "New script", None, self.domenu_new) | |
| 231 #self.scriptsmenu.addseparator() | |
| 232 fss, fss_changed = self.scriptsfolder.Resolve() | |
| 233 self.scriptswalk(fss.as_pathname(), self.scriptsmenu) | |
| 234 | |
| 235 def makeopenwindowsmenu(self): | |
| 236 for i in range(len(self.openwindowsmenu.items)): | |
| 237 self.openwindowsmenu.menu.DeleteMenuItem(1) | |
| 238 self.openwindowsmenu.items = [] | |
| 239 windows = [] | |
| 240 self._openwindows = {} | |
| 241 for window in self._windows.keys(): | |
| 242 title = window.GetWTitle() | |
| 243 if not title: | |
| 244 title = "<no title>" | |
|
11949
5e48d83c0fce
Fixed multi-arg appends.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11325
diff
changeset
|
245 windows.append((title, window)) |
| 10047 | 246 windows.sort() |
| 247 for title, window in windows: | |
| 248 if title == "Python Interactive": # ugly but useful hack by Joe Strout | |
| 249 shortcut = '0' | |
| 250 else: | |
| 251 shortcut = None | |
| 252 item = FrameWork.MenuItem(self.openwindowsmenu, title, shortcut, callback = self.domenu_openwindows) | |
| 253 self._openwindows[item.item] = window | |
| 254 self._openwindowscheckmark = 0 | |
| 255 self.checkopenwindowsmenu() | |
| 256 | |
| 257 def domenu_openwindows(self, id, item, window, event): | |
| 258 w = self._openwindows[item] | |
| 259 w.ShowWindow() | |
| 260 w.SelectWindow() | |
| 261 | |
| 262 def domenu_quit(self): | |
| 263 self._quit() | |
| 264 | |
| 265 def domenu_save(self, *args): | |
| 266 print "Save" | |
| 267 | |
| 268 def _quit(self): | |
| 269 import PyConsole, PyEdit | |
| 270 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
|
271 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
|
272 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
|
273 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
|
274 rv = 0 # (otherwise, we can get stuck!) |
| 10047 | 275 if rv and rv > 0: |
| 276 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
|
277 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
|
278 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
|
279 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
|
280 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
|
281 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
|
282 # 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
|
283 # 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
|
284 # 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
|
285 # 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
|
286 sys.__stderr__.write("*** PythonIDE: Can't write preferences ***\n") |
| 10047 | 287 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
|
288 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
289 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
|
290 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
|
291 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
|
292 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
|
293 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
|
294 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
|
295 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
|
296 if runningOnOSX(): |
|
bf90fb71aa76
Reorganized order of help menu, and don't show Carbon documentation
Jack Jansen <jack.jansen@cwi.nl>
parents:
25084
diff
changeset
|
297 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
|
298 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
|
299 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
|
300 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
|
301 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
|
302 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
|
303 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
|
304 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
305 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
|
306 from Carbon import AH |
|
25224
e709a3c8bfec
Pass None to AHGotoPage().
Jack Jansen <jack.jansen@cwi.nl>
parents:
25156
diff
changeset
|
307 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
|
308 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
309 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
|
310 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
|
311 try: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
312 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
|
313 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
|
314 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
|
315 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
|
316 else: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
317 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
|
318 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
319 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
|
320 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
|
321 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
|
322 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
|
323 return |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
324 try: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
325 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
|
326 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
|
327 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
|
328 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
329 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
|
330 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
|
331 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
|
332 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
|
333 return |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
334 try: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
335 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
|
336 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
|
337 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
|
338 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
339 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
|
340 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
|
341 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
|
342 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
|
343 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
|
344 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
|
345 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
|
346 # 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
|
347 # 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
|
348 # 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
|
349 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
|
350 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
|
351 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
352 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
|
353 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
|
354 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
|
355 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
|
356 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
|
357 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
|
358 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
|
359 else: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
360 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
|
361 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
|
362 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
363 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
|
364 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
|
365 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
|
366 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
367 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
|
368 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
|
369 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
|
370 |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
371 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
|
372 # 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
|
373 # 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
|
374 # 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
|
375 # 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
|
376 # 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
|
377 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
|
378 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
|
379 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
|
380 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
|
381 try: |
|
b337ef16c0d2
Implemented the Help menu. The Python manual can be viewed (if installed)
Jack Jansen <jack.jansen@cwi.nl>
parents:
24226
diff
changeset
|
382 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
|
383 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
|
384 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
|
385 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
|
386 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
|
387 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
|
388 |
| 10047 | 389 |
| 390 PythonIDE() | |
| 391 |
