コード例 #1
0
ファイル: draw.py プロジェクト: BackupTheBerlios/pyformex-svn
def saveMulti(fn=None,fmt=None,verbose=False):
    """Save a sequence of images.

    If the filename supplied has a trailing numeric part, subsequent images
    will be numbered continuing from this number. Otherwise a numeric part
    -000, -001, will be added to the filename.

    Without filename, switches off multisave mode.
    """
    global multisave
    # Leave multisave mode
    if not fn:
        if multisave:
            log("Leaving multi save mode")
            QtCore.QObject.disconnect(GD.canvas,QtCore.SIGNAL("Save"),saveNext)
        multisave = None
        return

    # Enter multisave mode
    log("Entering multiple save mode to files:")
    setWorkdirFromFile(fn)
    name,ext = os.path.splitext(fn)
    fmt = utils.imageFormatFromExt(ext)
    log("%s-???.%s (%s)" % (name,ext,fmt))
    fmt = checkImageFormat(fmt,verbose)
    if fmt:
        name,number = utils.splitEndDigits(name)
        if len(number) > 0:
            nr = int(number)
            name += "%%0%dd" % len(number)
        else:
            nr = 0
            name += "-%03d"
        if len(ext) == 0:
            ext = '.%s' % fmt.lower()
        name += ext
        if verbose:
            warning("Each time you hit the 'S' key,\nthe image will be saved to the next number.")
        QtCore.QObject.connect(GD.canvas,QtCore.SIGNAL("Save"),saveNext)
        multisave = [ name,nr,fmt ]
コード例 #2
0
ファイル: FeEx.py プロジェクト: BackupTheBerlios/pyformex-svn
def numericEnd(s):
    i = utils.splitEndDigits(s)
    if len(i[1]) > 0:
        return int(i[1])
    else:
        return -1