Kaydet (Commit) 3c06b9a7 authored tarafından Jack Jansen's avatar Jack Jansen

Use the new macresource module to open the accompanying resource file (if needed).

üst a5d7da52
......@@ -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):
......
......@@ -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):
......
......@@ -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):
......
......@@ -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)
......
......@@ -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):
......
......@@ -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():
......
......@@ -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):
......
......@@ -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)
......
......@@ -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)
......
......@@ -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:
......
......@@ -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:
......
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment