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)
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)
def init(): import MacOS if hasattr(MacOS, 'EnableAppswitch'): MacOS.EnableAppswitch(-1) try: import autoGIL except ImportError: pass else: autoGIL.installAutoGIL() from Carbon import Qd, QuickDraw Qd.SetCursor(Qd.GetCursor(QuickDraw.watchCursor).data) 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(1, ide_path)
def init(): import MacOS if hasattr(MacOS, 'EnableAppswitch'): MacOS.EnableAppswitch(-1) try: import autoGIL except ImportError: pass else: autoGIL.installAutoGIL() from Carbon import Qd, QuickDraw Qd.SetCursor(Qd.GetCursor(QuickDraw.watchCursor).data) 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(1, ide_path)
def main(): """Main routine: open resource file, call dialog handler""" macresource.need("DLOG", ID_MAIN, "dnslookup-1.rsrc") do_dialog()
def main(): macresource.need('DLOG', ID_MAIN, "oldPICTbrowse.rsrc") PICTbrowse()
"""macfreezegui - The GUI for macfreeze"""
#
def _initialize(): global _initialized if _initialized: return macresource.need('DLOG', 260, 'dialogs.rsrc', __name__)
def main(): macresource.need("DLOG", ID_MAIN, "dnslookup-2.rsrc") DNSLookup()
def main(): macresource.need("DLOG", ID_MAIN, "PICTbrowse.rsrc") CIconbrowse()
"""Create a standalone application from a Python script. This puts up a dialog asking for a Python source file ('TEXT'). The output is a file with the same name but its ".py" suffix dropped. It is created by copying an applet template, all used shared libs and then adding 'PYC ' resources containing compiled versions of all used modules written in Python and the main script itself, as __main__. """ import sys import string import os import macfs import MacOS from Carbon import Res from Carbon import Dlg import EasyDialogs import buildtools import macresource # Hmmm... MACFREEZEPATH = os.path.join(sys.prefix, ":Mac:Tools:macfreeze") if MACFREEZEPATH not in sys.path: sys.path.append(MACFREEZEPATH) import macgen_bin # dialog, items DLG_ID = 400 OK_BUTTON = 1 CANCEL_BUTTON = 2 GENFAT_BUTTON = 4 GENPPC_BUTTON = 5 GEN68K_BUTTON = 6
"""browsepict - Display all "PICT" resources found"""
import FrameWork
"""Sample program performing domain name lookups and showing off EasyDialogs,
def dialog(script=None): # Invent the various names if not script: fss, ok = macfs.PromptGetFile("Script?", "TEXT") if not ok: sys.exit(0) script = fss.as_pathname() basename, ext = os.path.splitext(script) if ext: appletname = basename rsrcname = basename + 'modules.rsrc' else: appletname = script + '.applet' rsrcname = script + 'modules.rsrc' dirname, basebase = os.path.split(basename) dirname = os.path.join(dirname, 'build.'+basebase) # Get the dialog, possibly opening the resource file (if needed) 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) # Fill the dialog d.SetDialogDefaultItem(ITEM_OK) d.SetDialogCancelItem(ITEM_CANCEL) _dialogsetfile(d, ITEM_SCRIPTNAME, script) _dialogsetfile(d, ITEM_SOURCEDIRNAME, dirname) _dialogsetfile(d, ITEM_RESOURCENAME, rsrcname) _dialogsetfile(d, ITEM_APPLETNAME, appletname) gentype = ITEM_GENSOURCE _dialogradiogroup(d, ITEM_GENSOURCE) # Interact d.GetDialogWindow().SetWTitle("Standalone application creation options") d.GetDialogWindow().ShowWindow() d.DrawDialog() while 1: item = Dlg.ModalDialog(None) if item == ITEM_OK: break elif item == ITEM_CANCEL: sys.exit(0) elif item in RADIO_GROUPING.keys(): gentype = item _dialogradiogroup(d, item) elif item == ITEM_SCRIPTBROWSE: fss, ok = macfs.PromptGetFile("Script?") if ok: script = fss.as_pathname() _dialogsetfile(d, ITEM_SCRIPTNAME, script) elif item == ITEM_SOURCEDIRBROWSE: fss, ok = macfs.StandardPutFile("Output folder name", os.path.split(dirname)[1]) if ok: dirname = fss.as_pathname() _dialogsetfile(d, ITEM_SOURCEDIRNAME, dirname) elif item == ITEM_RESOURCEBROWSE: fss, ok = macfs.StandardPutFile("Resource output file", os.path.split(rsrcname)[1]) if ok: rsrcname = fss.as_pathname() _dialogsetfile(d, ITEM_RESOURCENAME, rsrcname) elif item == ITEM_APPLETBROWSE: fss, ok = macfs.StandardPutFile("Applet output file", os.path.split(appletname)[1]) if ok: appletname = fss.as_pathname() _dialogsetfile(d, ITEM_APPLETNAME, appletname) else: pass tp, h, rect = d.GetDialogItem(ITEM_DEBUG) debug = Dlg.GetDialogItemText(h) try: debug = string.atoi(string.strip(debug)) except ValueError: EasyDialogs.Message("Illegal debug value %r, set to zero."%(debug,)) debug = 0 if gentype == ITEM_GENSOURCE: return 'source', script, dirname, debug elif gentype == ITEM_GENRESOURCE: return 'resource', script, rsrcname, debug elif gentype == ITEM_GENAPPLET: return 'applet', script, appletname, debug elif gentype == ITEM_GENINFO: return 'info', script, '', debug raise 'Error in gentype', gentype
def _initialize(): global _initialized if _initialized: return macresource.need("DLOG", 260, "dialogs.rsrc", __name__)
"""browsepict - Display all "cicn" resources found"""
def InitUI(): """Initialize stuff needed by UI (a resource file)""" macresource.need('DLOG', ID_MAIN, 'MkDistr.rsrc', modname=__name__)
def main(): macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc") ICONbrowse()
"""Edit the Python Preferences file."""