diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2001-08-27 21:41:23 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2001-08-27 21:41:23 (GMT) |
commit | 3c06b9a7d4fa144eebd4786f71c4a301726e0c3c (patch) | |
tree | 4f9cdc3420a0b7d6cd76ec44245df09628e98993 /Mac | |
parent | a5d7da528bda145426c50ad9ded8d0707d5f302c (diff) | |
download | cpython-3c06b9a7d4fa144eebd4786f71c4a301726e0c3c.zip cpython-3c06b9a7d4fa144eebd4786f71c4a301726e0c3c.tar.gz cpython-3c06b9a7d4fa144eebd4786f71c4a301726e0c3c.tar.bz2 |
Use the new macresource module to open the accompanying resource file (if needed).
Diffstat (limited to 'Mac')
-rw-r--r-- | Mac/Demo/PICTbrowse/ICONbrowse.py | 10 | ||||
-rw-r--r-- | Mac/Demo/PICTbrowse/PICTbrowse.py | 10 | ||||
-rw-r--r-- | Mac/Demo/PICTbrowse/PICTbrowse2.py | 10 | ||||
-rw-r--r-- | Mac/Demo/PICTbrowse/cicnbrowse.py | 14 | ||||
-rw-r--r-- | Mac/Demo/PICTbrowse/oldPICTbrowse.py | 10 | ||||
-rw-r--r-- | Mac/Demo/example1/dnslookup-1.py | 10 | ||||
-rw-r--r-- | Mac/Demo/example2/dnslookup-2.py | 10 | ||||
-rw-r--r-- | Mac/Tools/IDE/PythonIDE.py | 24 | ||||
-rw-r--r-- | Mac/Tools/macfreeze/macfreezegui.py | 14 | ||||
-rw-r--r-- | Mac/scripts/BuildApplication.py | 9 | ||||
-rw-r--r-- | Mac/scripts/EditPythonPrefs.py | 6 | ||||
-rw-r--r-- | Mac/scripts/MkDistr_ui.py | 5 | ||||
-rw-r--r-- | Mac/scripts/fullbuild.py | 7 |
13 files changed, 37 insertions, 102 deletions
diff --git a/Mac/Demo/PICTbrowse/ICONbrowse.py b/Mac/Demo/PICTbrowse/ICONbrowse.py index 162fcb6..902b5c7 100644 --- a/Mac/Demo/PICTbrowse/ICONbrowse.py +++ b/Mac/Demo/PICTbrowse/ICONbrowse.py @@ -10,6 +10,7 @@ from Carbon import List import sys import struct from Carbon import Icn +import macresource # # Resource definitions @@ -26,14 +27,7 @@ MAXWIDTH=320 MAXHEIGHT=320 def main(): - try: - dummy = Res.GetResource('DLOG', ID_MAIN) - except Res.Error: - try: - Res.FSpOpenResFile("PICTbrowse.rsrc", 1) - except Res.Error, arg: - EasyDialogs.Message("Cannot open PICTbrowse.rsrc: "+arg[1]) - sys.exit(1) + macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc") ICONbrowse() class ICONbrowse(FrameWork.Application): diff --git a/Mac/Demo/PICTbrowse/PICTbrowse.py b/Mac/Demo/PICTbrowse/PICTbrowse.py index e45b18c..41ffa5c 100644 --- a/Mac/Demo/PICTbrowse/PICTbrowse.py +++ b/Mac/Demo/PICTbrowse/PICTbrowse.py @@ -9,6 +9,7 @@ from Carbon import Controls from Carbon import List import sys import struct +import macresource # # Resource definitions @@ -21,14 +22,7 @@ LEFT=200 TOP=64 def main(): - try: - dummy = Res.GetResource('DLOG', ID_MAIN) - except Res.Error: - try: - Res.FSpOpenResFile("PICTbrowse.rsrc", 1) - except Res.Error, arg: - EasyDialogs.Message("Cannot open PICTbrowse.rsrc: "+arg[1]) - sys.exit(1) + macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc") PICTbrowse() class PICTbrowse(FrameWork.Application): diff --git a/Mac/Demo/PICTbrowse/PICTbrowse2.py b/Mac/Demo/PICTbrowse/PICTbrowse2.py index 7e146ed..0e11681 100644 --- a/Mac/Demo/PICTbrowse/PICTbrowse2.py +++ b/Mac/Demo/PICTbrowse/PICTbrowse2.py @@ -9,6 +9,7 @@ from Carbon import Controls from Carbon import List import sys import struct +import macresource # # Resource definitions @@ -25,14 +26,7 @@ MAXWIDTH=320 MAXHEIGHT=320 def main(): - try: - dummy = Res.GetResource('DLOG', ID_MAIN) - except Res.Error: - try: - Res.FSpOpenResFile("PICTbrowse.rsrc", 1) - except Res.Error, arg: - EasyDialogs.Message("Cannot open PICTbrowse.rsrc: "+arg[1]) - sys.exit(1) + macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc") PICTbrowse() class PICTbrowse(FrameWork.Application): diff --git a/Mac/Demo/PICTbrowse/cicnbrowse.py b/Mac/Demo/PICTbrowse/cicnbrowse.py index 89f8218..561dcf9 100644 --- a/Mac/Demo/PICTbrowse/cicnbrowse.py +++ b/Mac/Demo/PICTbrowse/cicnbrowse.py @@ -10,6 +10,7 @@ from Carbon import List import sys import struct from Carbon import Icn +import macresource # # Resource definitions @@ -26,14 +27,7 @@ MAXWIDTH=320 MAXHEIGHT=320 def main(): - try: - dummy = Res.GetResource('DLOG', ID_MAIN) - except Res.Error: - try: - Res.FSpOpenResFile("PICTbrowse.rsrc", 1) - except Res.Error, arg: - EasyDialogs.Message("Cannot open PICTbrowse.rsrc: "+arg[1]) - sys.exit(1) + macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc") CIconbrowse() class CIconbrowse(FrameWork.Application): @@ -119,9 +113,9 @@ class MyDialog(FrameWork.DialogWindow): def open(self, id, contents): self.id = id FrameWork.DialogWindow.open(self, ID_MAIN) - self.wid.SetDialogDefaultItem(MAIN_SHOW) + self.dlg.SetDialogDefaultItem(MAIN_SHOW) self.contents = contents - self.ctl = self.wid.GetDialogItemAsControl(MAIN_LIST) + self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST) h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart, Controls.kControlListBoxListHandleTag) self.list = List.as_List(h) diff --git a/Mac/Demo/PICTbrowse/oldPICTbrowse.py b/Mac/Demo/PICTbrowse/oldPICTbrowse.py index 01cf71c..dc1f5b4 100644 --- a/Mac/Demo/PICTbrowse/oldPICTbrowse.py +++ b/Mac/Demo/PICTbrowse/oldPICTbrowse.py @@ -8,6 +8,7 @@ from Carbon import Win from Carbon import List import sys import struct +import macresource # # Resource definitions @@ -20,14 +21,7 @@ LEFT=200 TOP=64 def main(): - try: - dummy = Res.GetResource('DLOG', ID_MAIN) - except Res.Error: - try: - Res.FSpOpenResFile("oldPICTbrowse.rsrc", 0) - except Res.Error, arg: - EasyDialogs.Message("Cannot open PICTbrowse.rsrc: "+arg[1]) - sys.exit(1) + macresource.need('DLOG', ID_MAIN, "oldPICTbrowse.rsrc") PICTbrowse() class PICTbrowse(FrameWork.Application): diff --git a/Mac/Demo/example1/dnslookup-1.py b/Mac/Demo/example1/dnslookup-1.py index 9a2ab28..2aa7c88 100644 --- a/Mac/Demo/example1/dnslookup-1.py +++ b/Mac/Demo/example1/dnslookup-1.py @@ -7,6 +7,7 @@ from Carbon import Dlg import sys import socket import string +import macresource # # Definitions for our resources ID_MAIN=512 @@ -15,15 +16,10 @@ ITEM_LOOKUP_ENTRY=1 ITEM_RESULT=2 ITEM_LOOKUP_BUTTON=3 ITEM_QUIT_BUTTON=4 - - + def main(): """Main routine: open resource file, call dialog handler""" - try: - Res.FSpOpenResFile("dnslookup-1.rsrc", 1) - except Res.Error: - EasyDialogs.Message("Cannot open dnslookup-1.rsrc") - sys.exit(1) + macresource.need("DLOG", ID_MAIN, "dnslookup-1.rsrc") do_dialog() def do_dialog(): diff --git a/Mac/Demo/example2/dnslookup-2.py b/Mac/Demo/example2/dnslookup-2.py index 20e7fa5..9747c4a 100644 --- a/Mac/Demo/example2/dnslookup-2.py +++ b/Mac/Demo/example2/dnslookup-2.py @@ -5,6 +5,7 @@ from Carbon import Dlg import sys import socket import string +import macresource # # Definitions for our resources ID_MAIN=512 @@ -15,14 +16,7 @@ ITEM_RESULT=2 ITEM_LOOKUP_BUTTON=3 def main(): - try: - dummy = Res.GetResource('DLOG', ID_MAIN) - except Res.Error: - try: - Res.FSpOpenResFile("dnslookup-2.rsrc", 1) - except Res.Error: - EasyDialogs.Message("Cannot open dnslookup-2.rsrc") - sys.exit(1) + macresource.need("DLOG", ID_MAIN, "dnslookup-2.rsrc") DNSLookup() class DNSLookup(FrameWork.Application): diff --git a/Mac/Tools/IDE/PythonIDE.py b/Mac/Tools/IDE/PythonIDE.py index bc22e79..5ebe97a 100644 --- a/Mac/Tools/IDE/PythonIDE.py +++ b/Mac/Tools/IDE/PythonIDE.py @@ -13,25 +13,17 @@ def init(): from Carbon import Qd, QuickDraw Qd.SetCursor(Qd.GetCursor(QuickDraw.watchCursor).data) - from Carbon import Res + import macresource import sys, os - try: - Res.GetResource('DITL', 468) - except Res.Error: - # we're not an applet - Res.FSpOpenResFile(os.path.join(sys.exec_prefix, ":Mac:Tools:IDE:PythonIDE.rsrc"), 1) - Res.FSpOpenResFile(os.path.join(sys.exec_prefix, ":Mac:Tools:IDE:Widgets.rsrc"), 1) + macresource.need('DITL', 468, "PythonIDE.rsrc") + widgetresfile = os.path.join(sys.exec_prefix, ":Mac:Tools:IDE:Widgets.rsrc") + 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") else: - # we're an applet - try: - Res.GetResource('CURS', 468) - except Res.Error: - Res.FSpOpenResFile(os.path.join(sys.exec_prefix, ":Mac:Tools:IDE:Widgets.rsrc"), 1) - ide_path = os.path.join(sys.exec_prefix, ":Mac:Tools:IDE") - else: - # we're a full blown applet - ide_path = sys.argv[0] + # We are a fully frozen application + ide_path = sys.argv[0] if ide_path not in sys.path: sys.path.insert(0, ide_path) diff --git a/Mac/Tools/macfreeze/macfreezegui.py b/Mac/Tools/macfreeze/macfreezegui.py index a834138..7921a29 100644 --- a/Mac/Tools/macfreeze/macfreezegui.py +++ b/Mac/Tools/macfreeze/macfreezegui.py @@ -6,6 +6,7 @@ import sys import os import string from Carbon import Res +import macresource ID_MAINDIALOG=512 @@ -54,17 +55,8 @@ def dialog(script=None): dirname = os.path.join(dirname, 'build.'+basebase) # Get the dialog, possibly opening the resource file (if needed) - try: - d = Dlg.GetNewDialog(ID_MAINDIALOG, -1) - except Dlg.Error: - d = None - if d == None: - try: - Res.FSpOpenResFile('macfreeze.rsrc', 1) - except Res.Error: - d = None - else: - d = Dlg.GetNewDialog(ID_MAINDIALOG, -1) + macresource.need('DLOG', ID_MAINDIALOG, 'macfreeze.rsrc') + d = Dlg.GetNewDialog(ID_MAINDIALOG, -1) if d == None: EasyDialogs.Message("Dialog resource not found or faulty") sys.exit(1) diff --git a/Mac/scripts/BuildApplication.py b/Mac/scripts/BuildApplication.py index ee82b7a..a7c8f40 100644 --- a/Mac/scripts/BuildApplication.py +++ b/Mac/scripts/BuildApplication.py @@ -18,6 +18,7 @@ from Carbon import Res from Carbon import Dlg import EasyDialogs import buildtools +import macresource # Hmmm... MACFREEZEPATH = os.path.join(sys.prefix, ":Mac:Tools:macfreeze") @@ -38,13 +39,7 @@ GEN68K_BUTTON = 6 PPC_ONLY=1 -try: - Res.GetResource('DITL', DLG_ID) -except Res.Error: - Res.FSpOpenResFile("BuildApplication.rsrc", 1) -else: - pass # we're an applet - +macresource.need('DITL', DLG_ID, "BuildApplication.rsrc") def main(): try: diff --git a/Mac/scripts/EditPythonPrefs.py b/Mac/scripts/EditPythonPrefs.py index 00119e0..833e607 100644 --- a/Mac/scripts/EditPythonPrefs.py +++ b/Mac/scripts/EditPythonPrefs.py @@ -15,6 +15,7 @@ import os import sys from Carbon import Res # For Res.Error import pythonprefs +import macresource import EasyDialogs try: from Carbon import Help @@ -195,10 +196,7 @@ def edit_applet(name): handler.save(result) def main(): - try: - h = FSpOpenResFile('EditPythonPrefs.rsrc', 1) - except Res.Error: - pass # Assume we already have acces to our own resource + macresource.need('DLOG', DIALOG_ID, 'EditPythonPrefs.rsrc') MacOS.SchedParams(1, 0) if len(sys.argv) <= 1: diff --git a/Mac/scripts/MkDistr_ui.py b/Mac/scripts/MkDistr_ui.py index 3ea78a9..5386950 100644 --- a/Mac/scripts/MkDistr_ui.py +++ b/Mac/scripts/MkDistr_ui.py @@ -23,6 +23,7 @@ import EasyDialogs import macfs import os import sys +import macresource # Resource IDs ID_MAIN = 514 @@ -321,7 +322,7 @@ def GetType(): def InitUI(): """Initialize stuff needed by UI (a resource file)""" - Res.FSpOpenResFile('MkDistr.rsrc', 1) + macresource.need('DLOG', ID_MAIN, 'MkDistr.rsrc', modname=__name__) class _testerhelp: def __init__(self, which): @@ -340,7 +341,7 @@ class _testerhelp: class _test: def __init__(self): import sys - Res.FSpOpenResFile('MkDistr.rsrc', 1) + InitUI() self.inc = _testerhelp('include') self.exc = _testerhelp('exclude') self.ui = MkDistrUI(self) diff --git a/Mac/scripts/fullbuild.py b/Mac/scripts/fullbuild.py index f5ccfc9..8954739 100644 --- a/Mac/scripts/fullbuild.py +++ b/Mac/scripts/fullbuild.py @@ -19,6 +19,7 @@ import EasyDialogs import re import string import genpluginprojects +import macresource import aetools from Carbon import AppleEvents @@ -369,11 +370,7 @@ def incbuildno(filename): fp.close() def main(): - try: - h = Res.FSpOpenResFile('fullbuild.rsrc', 1) - except Res.Error: - pass # Assume we already have acces to our own resource - + macresource.need('DLOG', DIALOG_ID, 'fullbuild.rsrc') dir, ok = macfs.GetDirectory('Python source folder:') if not ok: sys.exit(0) |