]> granicus.if.org Git - python/commitdiff
Allow this to run both standalone and as a window in the IDE.
authorJack Jansen <jack.jansen@cwi.nl>
Wed, 12 Feb 2003 15:39:56 +0000 (15:39 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Wed, 12 Feb 2003 15:39:56 +0000 (15:39 +0000)
Mac/Tools/IDE/PackageManager.py

index a93d68311f5d61bed049123db51b3b3026c5df96..6b83e1c5ad5accea7a450c40cda22f10805cf742 100755 (executable)
@@ -1,3 +1,37 @@
+# Prelude to allow running this as a main program
+def _init():
+       import macresource
+       import sys, os
+       macresource.need('DITL', 468, "PythonIDE.rsrc")
+       widgetrespathsegs = [sys.exec_prefix, "Mac", "Tools", "IDE", "Widgets.rsrc"]
+       widgetresfile = os.path.join(*widgetrespathsegs)
+       if not os.path.exists(widgetresfile):
+               widgetrespathsegs = [os.pardir, "Tools", "IDE", "Widgets.rsrc"]
+               widgetresfile = os.path.join(*widgetrespathsegs)
+       refno = macresource.need('CURS', 468, widgetresfile)
+       if os.environ.has_key('PYTHONIDEPATH'):
+               # For development set this environment variable
+               ide_path = os.environ['PYTHONIDEPATH']
+       elif refno:
+               # We're not a fullblown application
+               idepathsegs = [sys.exec_prefix, "Mac", "Tools", "IDE"]
+               ide_path = os.path.join(*idepathsegs)
+               if not os.path.exists(ide_path):
+                       idepathsegs = [os.pardir, "Tools", "IDE"]
+                       for p in sys.path:
+                               ide_path = os.path.join(*([p]+idepathsegs))
+                               if os.path.exists(ide_path):
+                                       break
+               
+       else:
+               # We are a fully frozen application
+               ide_path = sys.argv[0]
+       if ide_path not in sys.path:
+               sys.path.insert(0, ide_path)
+               
+if __name__ == '__main__':
+       _init()
+       
 import W
 import Wapplication
 from Carbon import Evt
@@ -69,7 +103,7 @@ class PackageManagerMain(Wapplication.Application):
                
                self.openwindowsmenu = Wapplication.Menu(self.menubar, 'Windows')
                self.makeopenwindowsmenu()
-               self._menustocheck = [closeitem, saveasitem, 
+               self._menustocheck = [closeitem, 
                                undoitem, cutitem, copyitem, pasteitem, 
                                selallitem,
                                runitem, homepageitem]