summaryrefslogtreecommitdiffstats
path: root/Mac/Tools
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2002-01-21 23:00:52 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2002-01-21 23:00:52 (GMT)
commit815d2bf067799d519323a373387f342ec387645b (patch)
treee26ebc8bd231b418f77cd4357e7fe9936ecc5ac2 /Mac/Tools
parentc71efe01160653e1d232000889fe38f6cf4936c8 (diff)
downloadcpython-815d2bf067799d519323a373387f342ec387645b.zip
cpython-815d2bf067799d519323a373387f342ec387645b.tar.gz
cpython-815d2bf067799d519323a373387f342ec387645b.tar.bz2
Changes by Donovan Preston (and a few minor ones by me) to make IDE run under
MachoPython. Mainly making sure we don't call routines that don't exist and representing pathnames in a os.separator-neutral format. These shouldn't interfere too much with Just's work on the next generation IDE, I hope.
Diffstat (limited to 'Mac/Tools')
-rw-r--r--Mac/Tools/IDE/PyConsole.py12
-rw-r--r--Mac/Tools/IDE/PyDebugger.py6
-rw-r--r--Mac/Tools/IDE/PyDocSearch.py6
-rw-r--r--Mac/Tools/IDE/PyEdit.py6
-rw-r--r--Mac/Tools/IDE/PythonIDE.py12
-rw-r--r--Mac/Tools/IDE/PythonIDEMain.py25
-rw-r--r--Mac/Tools/IDE/Wapplication.py36
-rw-r--r--Mac/Tools/IDE/Wwindows.py6
8 files changed, 71 insertions, 38 deletions
diff --git a/Mac/Tools/IDE/PyConsole.py b/Mac/Tools/IDE/PyConsole.py
index 24fa059..6c0ecd7 100644
--- a/Mac/Tools/IDE/PyConsole.py
+++ b/Mac/Tools/IDE/PyConsole.py
@@ -75,9 +75,11 @@ class ConsoleTextWidget(W.EditText):
if char == Wkeys.returnkey:
text = self.get()[self._inputstart:selstart]
text = string.join(string.split(text, "\r"), "\n")
- saveyield = MacOS.EnableAppswitch(0)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ saveyield = MacOS.EnableAppswitch(0)
self.pyinteractive.executeline(text, self, self._namespace)
- MacOS.EnableAppswitch(saveyield)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(saveyield)
selstart, selend = self.getselection()
self._inputstart = selstart
@@ -275,13 +277,15 @@ class PyOutput:
self.w.bind("<activate>", self.activate)
def write(self, text):
- oldyield = MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ oldyield = MacOS.EnableAppswitch(-1)
try:
self._buf = self._buf + text
if '\n' in self._buf:
self.flush()
finally:
- MacOS.EnableAppswitch(oldyield)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(oldyield)
def flush(self):
self.show()
diff --git a/Mac/Tools/IDE/PyDebugger.py b/Mac/Tools/IDE/PyDebugger.py
index 4bbac26..74bfc74 100644
--- a/Mac/Tools/IDE/PyDebugger.py
+++ b/Mac/Tools/IDE/PyDebugger.py
@@ -496,7 +496,8 @@ class Debugger(bdb.Bdb):
self.w.panes.bottom.tracingmonitor.toggle()
try:
try:
- MacOS.EnableAppswitch(0)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(0)
if self.quitting:
# returning None is not enough, a former BdbQuit exception
# might have been eaten by the print statement
@@ -512,7 +513,8 @@ class Debugger(bdb.Bdb):
print 'bdb.Bdb.dispatch: unknown debugging event:', `event`
return self.trace_dispatch
finally:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
except KeyboardInterrupt:
self.set_step()
return self.trace_dispatch
diff --git a/Mac/Tools/IDE/PyDocSearch.py b/Mac/Tools/IDE/PyDocSearch.py
index 208870e..98eced9 100644
--- a/Mac/Tools/IDE/PyDocSearch.py
+++ b/Mac/Tools/IDE/PyDocSearch.py
@@ -122,7 +122,8 @@ def dosearch(docpath, searchstring, settings):
_open = open
hits = {}
try:
- MacOS.EnableAppswitch(0)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(0)
try:
for do, name in books:
if not do:
@@ -145,7 +146,8 @@ def dosearch(docpath, searchstring, settings):
if filehits:
hits[fullpath] = filehits
finally:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
status.close()
except KeyboardInterrupt:
pass
diff --git a/Mac/Tools/IDE/PyEdit.py b/Mac/Tools/IDE/PyEdit.py
index 828b697..2117fc4 100644
--- a/Mac/Tools/IDE/PyEdit.py
+++ b/Mac/Tools/IDE/PyEdit.py
@@ -1128,7 +1128,8 @@ def execstring(pytext, globals, locals, filename="<string>", debugging=0,
else:
PyDebugger.startfromhere()
elif not haveThreading:
- MacOS.EnableAppswitch(0)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(0)
try:
if profiling:
import profile, ProfileBrowser
@@ -1145,7 +1146,8 @@ def execstring(pytext, globals, locals, filename="<string>", debugging=0,
exec code in globals, locals
finally:
if not haveThreading:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
except W.AlertError, detail:
raise W.AlertError, detail
except (KeyboardInterrupt, BdbQuit):
diff --git a/Mac/Tools/IDE/PythonIDE.py b/Mac/Tools/IDE/PythonIDE.py
index 5ebe97a..a2041e0 100644
--- a/Mac/Tools/IDE/PythonIDE.py
+++ b/Mac/Tools/IDE/PythonIDE.py
@@ -4,11 +4,13 @@
# it like the "normal" interpreter.
__version__ = '1.0.1'
-
+import sys
+import os
def init():
import MacOS
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
from Carbon import Qd, QuickDraw
Qd.SetCursor(Qd.GetCursor(QuickDraw.watchCursor).data)
@@ -16,11 +18,13 @@ def init():
import macresource
import sys, os
macresource.need('DITL', 468, "PythonIDE.rsrc")
- widgetresfile = os.path.join(sys.exec_prefix, ":Mac:Tools:IDE:Widgets.rsrc")
+ widgetrespathsegs = [sys.exec_prefix, "Mac", "Tools", "IDE", "Widgets.rsrc"]
+ widgetresfile = os.path.join(*widgetrespathsegs)
refno = macresource.need('CURS', 468, widgetresfile)
if refno:
# We're not a fullblown application
- ide_path = os.path.join(sys.exec_prefix, ":Mac:Tools:IDE")
+ idepathsegs = [sys.exec_prefix, "Mac", "Tools", "IDE"]
+ ide_path = os.path.join(*idepathsegs)
else:
# We are a fully frozen application
ide_path = sys.argv[0]
diff --git a/Mac/Tools/IDE/PythonIDEMain.py b/Mac/Tools/IDE/PythonIDEMain.py
index 680bd7b..f70f949 100644
--- a/Mac/Tools/IDE/PythonIDEMain.py
+++ b/Mac/Tools/IDE/PythonIDEMain.py
@@ -7,7 +7,12 @@ import Wapplication
import W
import os
import macfs
+import MacOS
+if MacOS.runtimemodel == 'macho':
+ ELIPSES = '...'
+else:
+ ELIPSES = '\xc9'
class PythonIDE(Wapplication.Application):
@@ -50,13 +55,13 @@ class PythonIDE(Wapplication.Application):
def makeusermenus(self):
m = Wapplication.Menu(self.menubar, "File")
newitem = FrameWork.MenuItem(m, "New", "N", 'new')
- openitem = FrameWork.MenuItem(m, "Open\xc9", "O", 'open')
+ openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open')
FrameWork.Separator(m)
closeitem = FrameWork.MenuItem(m, "Close", "W", 'close')
saveitem = FrameWork.MenuItem(m, "Save", "S", 'save')
- saveasitem = FrameWork.MenuItem(m, "Save as\xc9", None, 'save_as')
+ saveasitem = FrameWork.MenuItem(m, "Save as"+ELIPSES, None, 'save_as')
FrameWork.Separator(m)
- saveasappletitem = FrameWork.MenuItem(m, "Save as Applet\xc9", None, 'save_as_applet')
+ saveasappletitem = FrameWork.MenuItem(m, "Save as Applet"+ELIPSES, None, 'save_as_applet')
FrameWork.Separator(m)
quititem = FrameWork.MenuItem(m, "Quit", "Q", 'quit')
@@ -71,7 +76,7 @@ class PythonIDE(Wapplication.Application):
selallitem = FrameWork.MenuItem(m, "Select all", "A", "selectall")
sellineitem = FrameWork.MenuItem(m, "Select line", "L", "selectline")
FrameWork.Separator(m)
- finditem = FrameWork.MenuItem(m, "Find\xc9", "F", "find")
+ finditem = FrameWork.MenuItem(m, "Find"+ELIPSES, "F", "find")
findagainitem = FrameWork.MenuItem(m, "Find again", 'G', "findnext")
enterselitem = FrameWork.MenuItem(m, "Enter search string", "E", "entersearchstring")
replaceitem = FrameWork.MenuItem(m, "Replace", None, "replace")
@@ -84,12 +89,12 @@ class PythonIDE(Wapplication.Application):
runitem = FrameWork.MenuItem(m, "Run window", "R", 'run')
runselitem = FrameWork.MenuItem(m, "Run selection", None, 'runselection')
FrameWork.Separator(m)
- moditem = FrameWork.MenuItem(m, "Module browser\xc9", "M", self.domenu_modulebrowser)
+ moditem = FrameWork.MenuItem(m, "Module browser"+ELIPSES, "M", self.domenu_modulebrowser)
FrameWork.Separator(m)
mm = FrameWork.SubMenu(m, "Preferences")
- FrameWork.MenuItem(mm, "Set Scripts folder\xc9", None, self.do_setscriptsfolder)
- FrameWork.MenuItem(mm, "Editor default settings\xc9", None, self.do_editorprefs)
- FrameWork.MenuItem(mm, "Set default window font\xc9", None, self.do_setwindowfont)
+ FrameWork.MenuItem(mm, "Set Scripts folder"+ELIPSES, None, self.do_setscriptsfolder)
+ FrameWork.MenuItem(mm, "Editor default settings"+ELIPSES, None, self.do_editorprefs)
+ FrameWork.MenuItem(mm, "Set default window font"+ELIPSES, None, self.do_setwindowfont)
self.openwindowsmenu = Wapplication.Menu(self.menubar, 'Windows')
self.makeopenwindowsmenu()
@@ -110,7 +115,7 @@ class PythonIDE(Wapplication.Application):
path = os.path.join(os.getcwd(), "Scripts")
if not os.path.exists(path):
os.mkdir(path)
- f = open(os.path.join(path, "Place your scripts here\xc9"), "w")
+ f = open(os.path.join(path, "Place your scripts here"+ELIPSES), "w")
f.close()
fss = macfs.FSSpec(path)
self.scriptsfolder = fss.NewAlias()
@@ -159,7 +164,7 @@ class PythonIDE(Wapplication.Application):
W.Message("Can't open file of type '%s'." % ftype)
def getabouttext(self):
- return "About Python IDE\xc9"
+ return "About Python IDE"+ELIPSES
def do_about(self, id, item, window, event):
Splash.about()
diff --git a/Mac/Tools/IDE/Wapplication.py b/Mac/Tools/IDE/Wapplication.py
index 8839c90..40eb0c6 100644
--- a/Mac/Tools/IDE/Wapplication.py
+++ b/Mac/Tools/IDE/Wapplication.py
@@ -28,27 +28,33 @@ class Application(FrameWork.Application):
def mainloop(self, mask=FrameWork.everyEvent, wait=None):
import W
self.quitting = 0
- saveyield = MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ saveyield = MacOS.EnableAppswitch(-1)
try:
while not self.quitting:
try:
self.do1event(mask, wait)
except W.AlertError, detail:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
W.Message(detail)
except self.DebuggerQuit:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
except:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
import PyEdit
PyEdit.tracebackwindow.traceback()
finally:
- MacOS.EnableAppswitch(1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(1)
def debugger_mainloop(self, mask=FrameWork.everyEvent, wait=None):
import W
self.debugger_quitting = 0
- saveyield = MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ saveyield = MacOS.EnableAppswitch(-1)
try:
while not self.quitting and not self.debugger_quitting:
try:
@@ -59,7 +65,8 @@ class Application(FrameWork.Application):
import PyEdit
PyEdit.tracebackwindow.traceback()
finally:
- MacOS.EnableAppswitch(saveyield)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(saveyield)
def breathe(self, wait=1):
import W
@@ -309,19 +316,24 @@ class Application(FrameWork.Application):
# exec in that window's namespace.
# xxx what to do when it's not saved???
# promt to save?
- MacOS.EnableAppswitch(0)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(0)
execfile(path, {'__name__': '__main__', '__file__': path})
except W.AlertError, detail:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
raise W.AlertError, detail
except KeyboardInterrupt:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
except:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
import PyEdit
PyEdit.tracebackwindow.traceback(1)
else:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
#os.chdir(cwd)
def openscript(self, filename, lineno=None, charoffset=0, modname=""):
diff --git a/Mac/Tools/IDE/Wwindows.py b/Mac/Tools/IDE/Wwindows.py
index 20ed312..f0ac92b 100644
--- a/Mac/Tools/IDE/Wwindows.py
+++ b/Mac/Tools/IDE/Wwindows.py
@@ -455,7 +455,8 @@ class ModalDialog(Dialog):
Dialog.close(self)
def mainloop(self):
- saveyield = MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ saveyield = MacOS.EnableAppswitch(-1)
while not self.done:
#self.do1event()
self.do1event( Events.keyDownMask +
@@ -465,7 +466,8 @@ class ModalDialog(Dialog):
Events.mDownMask +
Events.mUpMask,
10)
- MacOS.EnableAppswitch(saveyield)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(saveyield)
def do1event(self, mask = Events.everyEvent, wait = 0):
ok, event = self.app.getevent(mask, wait)