]> granicus.if.org Git - python/commitdiff
Changes by Donovan Preston (and a few minor ones by me) to make IDE run under
authorJack Jansen <jack.jansen@cwi.nl>
Mon, 21 Jan 2002 23:00:52 +0000 (23:00 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Mon, 21 Jan 2002 23:00:52 +0000 (23:00 +0000)
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.

Mac/Tools/IDE/PyConsole.py
Mac/Tools/IDE/PyDebugger.py
Mac/Tools/IDE/PyDocSearch.py
Mac/Tools/IDE/PyEdit.py
Mac/Tools/IDE/PythonIDE.py
Mac/Tools/IDE/PythonIDEMain.py
Mac/Tools/IDE/Wapplication.py
Mac/Tools/IDE/Wwindows.py

index 24fa0593df71bf7ce8742bb4c3bc7878077c8627..6c0ecd71343b7d15ed8ece6b5edfd304b945e6d4 100644 (file)
@@ -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()
index 4bbac262ca2127e76748c502ea45e394d45f7ae8..74bfc74d34bd997db059eeeb2d816a06fc354c38 100644 (file)
@@ -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
index 208870e3d0b529e297074ed24fb35d015aacf675..98eced916a6f6cbc9d8c6a97048cc91e68823b37 100644 (file)
@@ -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
index 828b697176e4c3486f3ab1936fd7f303a229c6ca..2117fc4d08ee6b1335273ccbc4d2cd4a6b5e4bb6 100644 (file)
@@ -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):
index 5ebe97afe29229fb63f05f5c3887bba5dfbcf1f1..a2041e0e55c25b73510f762fe32249175392d21a 100644 (file)
@@ -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]
index 680bd7be946fe3491e3269cc4013c59625bd7729..f70f94921528bc2ef5bbda32308d3fbb6b1b2f6e 100644 (file)
@@ -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()
index 8839c90a8b90d804f617dbef12025250218eb833..40eb0c67f3fd94f293187910e1483eeb3b35652f 100644 (file)
@@ -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=""):
index 20ed31294ead7a0e8ed3f9db14afcaabaf49c1ba..f0ac92bcfe6f32ddb78073225dfb85ae838f1620 100644 (file)
@@ -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)