コード例 #1
0
def rsrcGetCreator(path):
    if drawer.isCarbon():
        import Carbon.File
        fss = Carbon.File.FSSpec(path)
        finfo = fss.FSpGetFInfo()
        creator = finfo.Creator
        type = finfo.Type
    else:
        import macfs
        f = macfs.FSSpec(path)
        creator, type = f.GetCreatorType()
    return creator, type
コード例 #2
0
ファイル: osTools.py プロジェクト: ericahub/athenacl
def rsrcGetCreator(path):
    if drawer.isCarbon():
        import Carbon.File
        fss = Carbon.File.FSSpec(path)
        finfo = fss.FSpGetFInfo()
        creator = finfo.Creator
        type = finfo.Type
    else:
        import macfs
        f = macfs.FSSpec(path)
        creator, type = f.GetCreatorType()
    return creator, type
コード例 #3
0
def rsrcSetCreator(path, creator, type=None):
    if drawer.isCarbon():
        import Carbon.File
        fss = Carbon.File.FSSpec(path)
        finfo = fss.FSpGetFInfo()
        finfo.Creator = creator
        if type != None:
            finfo.Type = type
        fss.FSpSetFInfo(finfo)
    else:
        import macfs
        f = macfs.FSSpec(path)
        f.SetCreatorType(creator, type)
コード例 #4
0
ファイル: osTools.py プロジェクト: ericahub/athenacl
def rsrcSetCreator(path, creator, type=None):
    if drawer.isCarbon():
        import Carbon.File
        fss = Carbon.File.FSSpec(path)
        finfo = fss.FSpGetFInfo()
        finfo.Creator = creator
        if type != None:
            finfo.Type = type
        fss.FSpSetFInfo(finfo)
    else:
        import macfs
        f = macfs.FSSpec(path)
        f.SetCreatorType(creator, type) 
コード例 #5
0
def _macGetFile(prompt='pick a file', defaultDir=None):
    carbon = drawer.isCarbon()
    if carbon:
        import EasyDialogs
        path = EasyDialogs.AskFileForOpen(message=prompt)
        if path == None: return '', 0
        else: return path, 1
    else:
        import macfs
        fsspec, ok = macfs.PromptGetFile(prompt)
        if ok != 1: return '', 0  # failure
        path = fsspec.as_pathname()
        path = drawer.pathScrub(path)
        return path, 1
コード例 #6
0
ファイル: dialog.py プロジェクト: ericahub/athenacl
def _macGetFile(prompt='pick a file', defaultDir=None):
    carbon = drawer.isCarbon()
    if carbon:
        import EasyDialogs
        path = EasyDialogs.AskFileForOpen(message=prompt)
        if path == None: return '', 0
        else: return path, 1
    else:
        import macfs
        fsspec, ok = macfs.PromptGetFile(prompt)
        if ok != 1: return '', 0 # failure
        path = fsspec.as_pathname()
        path = drawer.pathScrub(path)
        return path, 1
コード例 #7
0
def _macGetDirectory(prompt='select a directory'):
    carbon = drawer.isCarbon()
    if carbon:
        import EasyDialogs
        path = EasyDialogs.AskFolder(message=prompt)
        if path == None: return '', 0
        else: return path, 1
    else:
        import macfs
        fsspec, ok = macfs.GetDirectory(prompt)
        if ok != 1:
            return '', 0  # failure
        path = fsspec.as_pathname()
        drawer.pathScrub(path)
        return path, 1
コード例 #8
0
ファイル: dialog.py プロジェクト: ericahub/athenacl
def _macGetDirectory(prompt='select a directory'):
    carbon = drawer.isCarbon()
    if carbon:
        import EasyDialogs
        path = EasyDialogs.AskFolder(message=prompt)
        if path == None: return '', 0
        else: return path, 1
    else:
        import macfs
        fsspec, ok = macfs.GetDirectory(prompt)
        if ok != 1:
            return '', 0 # failure
        path = fsspec.as_pathname()
        drawer.pathScrub(path)
        return path, 1
コード例 #9
0
def _macPutFile(prompt='save a file', defaultName='test.txt', defaultDir=None):
    carbon = drawer.isCarbon()
    if carbon:
        import EasyDialogs
        path = EasyDialogs.AskFileForSave(message=prompt,
                                          savedFileName=defaultName)
        if path == None: return '', 0
        else: return path, 1
    else:
        import macfs
        fsspec, ok = macfs.PromptPutFile(prompt, defaultName)
        if ok != 1:
            return '', 0
        path = fsspec.as_pathname()
        ## check extension, add if missing
        path = drawer.pathScrub(path)
        return path, 1
コード例 #10
0
ファイル: dialog.py プロジェクト: ericahub/athenacl
def _macPutFile(prompt='save a file', defaultName='test.txt', defaultDir=None):
    carbon = drawer.isCarbon()
    if carbon:
        import EasyDialogs
        path = EasyDialogs.AskFileForSave(message=prompt, 
                                        savedFileName=defaultName)
        if path == None: return '', 0
        else: return path, 1
    else:
        import macfs
        fsspec, ok = macfs.PromptPutFile(prompt, defaultName)
        if ok != 1:
            return '', 0
        path = fsspec.as_pathname()
        ## check extension, add if missing
        path = drawer.pathScrub(path)
        return path, 1
コード例 #11
0
def autoDlgMethod():
    """auto-detects which guis are available and selects one
    used when a dialog method is called without specifying
    which gui to use. acts as default selector (does _not_ use preference)
    """
    if os.name == 'mac':
        carbon = drawer.isCarbon()
        if carbon:  # macfs or carbon is available
            dlgVisualMethod = 'mac'
        else:  #-1 , use text
            dlgVisualMethod = 'text'
    elif os.name == 'posix':
        visMethods = drawer.imageFormats()
        if 'tk' in visMethods:
            dlgVisualMethod = 'tk'
        else:
            dlgVisualMethod = 'text'
    else:  # all windows flavors
        visMethods = drawer.imageFormats()
        if 'tk' in visMethods:
            dlgVisualMethod = 'tk'
        else:
            dlgVisualMethod = 'text'
    return dlgVisualMethod
コード例 #12
0
ファイル: dialog.py プロジェクト: ericahub/athenacl
def autoDlgMethod():
    """auto-detects which guis are available and selects one
    used when a dialog method is called without specifying
    which gui to use. acts as default selector (does _not_ use preference)
    """
    if os.name == 'mac':
        carbon = drawer.isCarbon()
        if carbon: # macfs or carbon is available
            dlgVisualMethod = 'mac'
        else: #-1 , use text
            dlgVisualMethod = 'text'
    elif os.name == 'posix':
        visMethods = drawer.imageFormats()
        if 'tk' in visMethods:
            dlgVisualMethod = 'tk'
        else:
            dlgVisualMethod = 'text'
    else:    # all windows flavors
        visMethods = drawer.imageFormats()
        if 'tk' in visMethods:
            dlgVisualMethod = 'tk'
        else:
            dlgVisualMethod = 'text'
    return dlgVisualMethod