def HomeResFile(res): """Return a path to the file in which resource 'res' lives.""" return GetFileLocation(res.HomeResFile()) def GetFileLocation(refNum): """Return a path to the open file identified with refNum.""" pb = ParamBlock(refNum) return pb.getPath() # # Internal cruft, adapted from MoreFiles # _InterfaceLib = calldll.getlibrary("InterfaceLib") GetVRefNum = calldll.newcall(_InterfaceLib.GetVRefNum, "None", "InShort", "OutShort") _getInfo = calldll.newcall(_InterfaceLib.PBGetFCBInfoSync, "Short", "InLong") _FCBPBFormat = """ qLink: l qType: h ioTrap: h ioCmdAddr: l ioCompletion: l ioResult: h ioNamePtr: l ioVRefNum: h ioRefNum: h filler: h
"""Tools for use in AppleEvent clients and servers: conversion between AE types and python types pack(x) converts a Python object to an AEDesc object unpack(desc) does the reverse coerce(x, wanted_sample) coerces a python object to another python object """ # # This code was originally written by Guido, and modified/extended by Jack # to include the various types that were missing. The reference used is # Apple Event Registry, chapter 9. # import struct import string import types from string import strip from types import * from Carbon import AE from Carbon.AppleEvents import * import MacOS import macfs import StringIO import baetypes from baetypes import mkenum, mktype import calldll OSL = calldll.getlibrary('ObjectSupportLib') # These ones seem to be missing from AppleEvents # (they're in AERegistry.h) #typeColorTable = 'clrt' #typeDrawingArea = 'cdrw' #typePixelMap = 'cpix'
# # Test calldll. Tell the user how often menus flash, and let her change it. # import calldll import sys # Obtain a reference to the library with the toolbox calls interfacelib = calldll.getlibrary('InterfaceLib') # Get the routines we need (see LowMem.h for details) LMGetMenuFlash = calldll.newcall(interfacelib.LMGetMenuFlash, 'Short') LMSetMenuFlash = calldll.newcall(interfacelib.LMSetMenuFlash, 'None', 'InShort') print "Menus currently flash",LMGetMenuFlash(),"times." print "How often would you like them to flash?", # Note: we use input(), so you can try passing non-integer objects newflash = input() LMSetMenuFlash(newflash) print "Okay, menus now flash", LMGetMenuFlash(),"times." sys.exit(1) # So the window stays on-screen
# # Test calldll. Tell the user how often menus flash, and let her change it. # import calldll import sys # Obtain a reference to the library with the toolbox calls interfacelib = calldll.getlibrary('InterfaceLib') # Get the routines we need (see LowMem.h for details) LMGetMenuFlash = calldll.newcall(interfacelib.LMGetMenuFlash, 'Short') LMSetMenuFlash = calldll.newcall(interfacelib.LMSetMenuFlash, 'None', 'InShort') print "Menus currently flash", LMGetMenuFlash(), "times." print "How often would you like them to flash?", # Note: we use input(), so you can try passing non-integer objects newflash = input() LMSetMenuFlash(newflash) print "Okay, menus now flash", LMGetMenuFlash(), "times." sys.exit(1) # So the window stays on-screen