Ejemplo n.º 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
Ejemplo n.º 2
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
Ejemplo n.º 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)
Ejemplo n.º 4
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) 
Ejemplo n.º 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
Ejemplo n.º 6
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
Ejemplo n.º 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
Ejemplo n.º 8
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
Ejemplo n.º 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
Ejemplo n.º 10
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
Ejemplo n.º 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
Ejemplo n.º 12
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