当前位置: 首页>>代码示例>>Python>>正文


Python utils.fileDescription函数代码示例

本文整理汇总了Python中utils.fileDescription函数的典型用法代码示例。如果您正苦于以下问题:Python fileDescription函数的具体用法?Python fileDescription怎么用?Python fileDescription使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了fileDescription函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: showImage

def showImage():
    """Display an image file."""
    global viewer
    fn = draw.askFilename(filter=utils.fileDescription('img'))
    if fn:
        viewer = ImageViewer(pf.app,fn)
        viewer.show()
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:7,代码来源:fileMenu.py

示例2: importDB

def importDB(fn=None):
    """Import a _post.py database and select it as the current."""
    
    if fn is None:
        types = utils.fileDescription('postproc')
        fn = askFilename(pf.cfg['workdir'],types)
    if fn:
        chdir(fn)
        size = os.stat(fn).st_size
        if size > 1000000 and ask("""
BEWARE!!!

The size of this file is very large: %s bytes
It is unlikely that I will be able to process this file.
I strongly recommend you to cancel the operation now.
""" % size,["Continue","Cancel"]) != "Continue":
            return

        # import the results DB
        play(fn)

        ### check whether the import succeeded
        name = FeResult._name_
        db = pf.PF[name]
        if not isinstance(db,FeResult):
            warning("!Something went wrong during the import of the database %s" % fn)
            return
        
        ### ok: select the DB
        selection.set([name])
        selectDB(db)
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:31,代码来源:postproc_menu.py

示例3: showImage

def showImage():
    """Display an image file."""
    global viewer
    fn = draw.askFilename(filter=utils.fileDescription('img'),multi=False,exist=True)
    if fn:
        viewer = ImageViewer(GD.app,fn)
        viewer.show()
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:7,代码来源:fileMenu.py

示例4: readSelection

def readSelection(select=True,draw=True,multi=True):
    """Read a Formex (or list) from asked file name(s).

    If select is True (default), this becomes the current selection.
    If select and draw are True (default), the selection is drawn.
    """
    types = utils.fileDescription(['pgf','all'])
    fn = askFilename(GD.cfg['workdir'],types,multi=multi)
    if fn:
        if not multi:
            fn = [ fn ]
        chdir(fn[0])
        res = ODict()
        GD.GUI.setBusy()
        for f in fn:
            res.update(readGeomFile(f))
        GD.GUI.setBusy(False)
        export(res)
        if select:
            oknames = [ k for k in res if isinstance(res[k],Formex) ]
            selection.set(oknames)
            GD.message("Set Formex selection to %s" % oknames)
            if draw:
                selection.draw()
    return fn
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:25,代码来源:formex_menu.py

示例5: importGeometry

def importGeometry(select=True,draw=True,ftype=None):
    """Read geometry from file.
    
    If select is True (default), the imported geometry becomes the current
    selection.
    If select and draw are True (default), the selection is drawn.
    """
    if ftype is None:
        ftype = ['pgf','pyf','surface','off','stl','gts','smesh','neu','all']
    else:
        ftype = [ftype]
    types = utils.fileDescription(ftype)
    cur = pf.cfg['workdir']
    fn = askFilename(cur=cur,filter=types)
    if fn:
        message("Reading geometry file %s" % fn)
        res = readGeometry(fn)
        export(res)
        #selection.readFromFile(fn)
        print res.keys()
        if select:
            selection.set(res.keys())
            if draw:
                selection.draw()
                zoomAll()
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:25,代码来源:geometry_menu.py

示例6: openScript

def openScript(fn=None,exist=True,create=False):
    """Open a pyFormex script and set it as the current script.

    If no filename is specified, a file selection dialog is started to select
    an existing script, or allow to create a new file if exist is False.

    If the file exists and is a pyFormex script, it is set ready to execute.

    If create is True, a default pyFormex script template will be written
    to the file, overwriting the contents if the file existed. Then, the
    script is loaded into the editor.

    We encourage the use of createScript() to create new scripts and leave
    openScript() to open existing scripts.
    """
    if fn is None:
        cur = GD.cfg.get('curfile',GD.cfg.get('workdir','.'))
        typ = utils.fileDescription('pyformex')
        fn = widgets.FileSelection(cur,typ,exist=exist).getFilename()
    if fn:
        if create:
            if not exist and os.path.exists(fn) and not draw.ack("The file %s already exists.\n Are you sure you want to overwrite it?" % fn):
                return None
            template = GD.cfg['scripttemplate']
            if (os.path.exists(template)):
                shutil.copyfile(template,fn)
        GD.cfg['workdir'] = os.path.dirname(fn)
        GD.GUI.setcurfile(fn)
        GD.GUI.history.add(fn)
        if create:
            editScript(fn)
    return fn
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:32,代码来源:fileMenu.py

示例7: convertGeometryFile

def convertGeometryFile():
    """Convert pyFormex geometry file to latest format."""
    filter = utils.fileDescription(['pgf','all'])
    cur = pf.cfg['workdir']
    fn = askFilename(cur=cur,filter=filter)
    if fn:
        from geomfile import GeometryFile
        message("Converting geometry file %s to version %s" % (fn,GeometryFile._version_))
        GeometryFile(fn).rewrite()
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:9,代码来源:geometry_menu.py

示例8: writeGeometry

def writeGeometry():
    """Write geometry to file."""
    drawable.ask()
    if drawable.check():
        filter = utils.fileDescription(['pgf','all'])
        cur = GD.cfg['workdir']
        fn = askNewFilename(cur=cur,filter=filter)
        if fn:
            drawable.writeToFile(fn)
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:9,代码来源:tools_menu.py

示例9: saveIcon

def saveIcon():
    """Save an image as icon.

    This will show the Save Image dialog, with the multisave mode off and
    asking for an icon file name. Then save the current rendering to that file.
    """
    ## We should create a specialized input dialog, asking also for the size 
    fn = draw.askFilename(filter=utils.fileDescription('icon'))
    if fn:
        image.saveIcon(fn,size=32)
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:10,代码来源:fileMenu.py

示例10: readGeometry

def readGeometry():
    """Read geometry from file."""
    filter = utils.fileDescription(['pgf','all'])
    cur = GD.cfg['workdir']
    fn = askFilename(cur=cur,filter=filter)
    if fn:
        drawable.readFromFile(fn)
        drawable.draw()
        zoomAll()
        print drawable.names
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:10,代码来源:tools_menu.py

示例11: openProject

def openProject(fn=None,exist=False,access=['wr','rw','w','r'],default=None):
    """Open a (new or old) Project file.

    A dialog is presented to ask the user for a Project file name and the
    access modalities. The parameters help in setting sensible defaults
    for the user and in delimiting his options.
    Depending on he results of the dialog, either a new project is created or
    an old one is opened, or nothing is done.
    If a project is opened, it is returned, else the return value is None.

    Parameters:

    - `fn`: filename: if specified, the Project file dialog will start with
      the specified file, otherwise it will start in the current directory.
    - `exist`: boolean: if False (default), the user can create new project
      files as well as open existing ones. Use exist=True or
      :func:`openExistingProject` to only accept existing project files.
    - `access`: a list of :class:`Project` access modes to be presented to
      the user.
    - `default`: the access mode that is presented as default to the user.
      If not specified, the first option of `access` will be the default.
    """
    if type(access) == str:
        access = [access]
    cur = fn if fn else '.'
    typ = utils.fileDescription(['pyf','all'])
    res = widgets.ProjectSelection(cur,typ,exist=exist,access=access,default=default,convert=True).getResult()
    if not res:
        return

    fn = res.fn
    if not fn.endswith('.pyf'):
        fn += '.pyf'
    access = res.acc
    compression = res.cpr
    convert = res.cvt
    signature = pf.fullVersion()

    # OK, we have all data, now create/open the project
    pf.message("Opening project %s" % fn)
    pf.GUI.setBusy() # loading  may take a while
    try:
        proj = project.Project(fn,access=access,convert=convert,signature=signature,compression=compression)
        if proj.signature != signature:
            pf.warning("The project was written with %s, while you are now running %s. If the latter is the newer one, this should probably not cause any problems. Saving is always done in the current format of the running version. Save your project and this message will be avoided on the next reopening." % (proj.signature,signature))
    except:
        proj = None
        raise
    finally:
        pf.GUI.setBusy(False)

    proj.hits = 0
    pf.debug("START COUNTING HITS",pf.DEBUG.PROJECT)
    return proj
开发者ID:dladd,项目名称:pyFormex,代码行数:54,代码来源:fileMenu.py

示例12: writeGeometry

def writeGeometry():
    """Write geometry to file."""
    drawable.ask()
    if drawable.check():
        filter = utils.fileDescription(['pgf','all'])
        cur = pf.cfg['workdir']
        fn = askNewFilename(cur=cur,filter=filter)
        if fn:
            if not fn.endswith('.pgf'):
                fn.append('.pgf')
            message("Writing geometry file %s" % fn)
            drawable.writeToFile(fn)
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:12,代码来源:tools_menu.py

示例13: importFlavia

def importFlavia(fn=None):
    """Import a flavia file and select it as the current results.

    Flavia files are the postprocessing format used by GiD pre- and
    postprocessor, and can also be written by the FE program calix.
    There usually are two files named 'BASE.flavia.msh' and 'BASE.flavia.res'
    which hold the FE mesh and results, respectively.
    
    This functions asks the user to select a flavia file (either mesh or
    results), will then read both the mesh and corrseponding results files,
    and store the results in a FeResult instance, which will be set as the
    current results database for the postprocessing menu.
    """
    from plugins.flavia import readFlavia
    if fn is None:
        types = [ utils.fileDescription('flavia'), utils.fileDescription('all') ]
        fn = askFilename(pf.cfg['workdir'],types)
    if fn:
        chdir(fn)
        if fn.endswith('.msh'):
            meshfile = fn
            resfile = utils.changeExt(fn,'res')
        else:
            resfile = fn
            meshfile = utils.changeExt(fn,'msh')
            
        db = readFlavia(meshfile,resfile)
        if not isinstance(db,FeResult):
            warning("!Something went wrong during the import of the flavia database %s" % fn)
            return

        ### ok: export and select the DB
        name = os.path.splitext(os.path.basename(fn))[0].replace('.flavia','')
        export({name:db})
        db.printSteps()
        print db.R
        print db.datasize
        
        selection.set([name])
        selectDB(db)
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:40,代码来源:postproc_menu.py

示例14: exportGeometry

def exportGeometry(types=['pgf','all'],shortlines=False):
    """Write geometry to file."""
    drawable.ask()
    if not drawable.check():
        return
    
    filter = utils.fileDescription(types)
    cur = pf.cfg['workdir']
    fn = askNewFilename(cur=cur,filter=filter)
    if fn:
        message("Writing geometry file %s" % fn)
        res = writeGeometry(drawable.odict(),fn,shortlines=shortlines)
        pf.message("Contents: %s" % res)
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:13,代码来源:geometry_menu.py

示例15: writeSelection

def writeSelection():
    """Writes the currently selected Formices to a Geometry File."""
    F = selection.check()
    if F:
        types = utils.fileDescription(['pgf','all'])
        name = selection.names[0]
        fn = askNewFilename(os.path.join(GD.cfg['workdir'],"%s.pgf" % name),
                            filter=types)
        if fn:
            if not (fn.endswith('.pgf') or fn.endswith('.formex')):
                fn += '.pgf'
            GD.message("Creating pyFormex Geometry File '%s'" % fn)
            chdir(fn)
            selection.writeToFile(fn)
            GD.message("Contents: %s" % selection.names)
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:15,代码来源:formex_menu.py


注:本文中的utils.fileDescription函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。