示例#1
0
def createMovieInteractive():
    """Create a movie from a saved sequence of images.

    """
    if not image.multisave:
        pf.warning('You need to start multisave mode first!')
        return

    names = image.multisave[0]
    glob = names.glob()

    res = draw.askItems([
        _I('files', glob),
        _I('encoder', choices=['mencoder', 'convert', 'ffmpeg']),
        _G('Mencoder', [
            _I('fps', 10),
            _I('vbirate', 800),
        ]),
        _G('Convert', [
            _I('delay', 1),
            _I('colors', 256),
        ]),
    ],
                        enablers=[
                            ('encoder', 'mencoder', 'Mencoder'),
                            ('encoder', 'convert', 'Convert'),
                        ])
    if not res:
        return

    pf.GUI.setBusy()
    image.createMovie(**res)
    pf.GUI.setBusy(False)
示例#2
0
def importProject():
    """Import an existing project.

    Ask the user to select an existing project file, and then import
    all or selected data from it into the current project.
    """
    proj = openProject(exist=True, access='r')
    if proj:  # only if non-empty
        keys = utils.sortedKeys(proj)
        res = draw.askItems(
            [
                _I('mode',
                   choices=['All', 'Defined', 'Undefined', 'Selected', 'None'],
                   itemtype='radio'),
                _I('selected', choices=keys, itemtype='list'),
            ],
            caption='Select variables to import',
        )
        if res:
            mode = res['mode'][0]
            if mode == 'A':
                pass
            elif mode == 'D':
                proj = utils.selectDict(proj, pf.PF)
            elif mode == 'U':
                proj = utils.removeDict(proj, pf.PF)
            elif mode == 'S':
                proj = utils.selectDict(proj, res['selected'])
            elif mode == 'N':
                return
            pf.message("Importing symbols: %s" % utils.sortedKeys(proj))
            pf.PF.update(proj)
            listProject()
示例#3
0
def importProject():
    """Import an existing project.

    Ask the user to select an existing project file, and then import
    all or selected data from it into the current project.
    """
    proj = openProject(exist=True,access='r')
    if proj: # only if non-empty
        keys = utils.sortedKeys(proj)
        res = draw.askItems(
            [   _I('mode',choices=['All','Defined','Undefined','Selected','None'],itemtype='radio'),
                _I('selected',choices=keys,itemtype='list'),
                ],
            caption='Select variables to import',
            )
        if res:
            mode = res['mode'][0]
            if mode == 'A':
                pass
            elif mode == 'D':
                proj = utils.selectDict(proj,pf.PF)
            elif mode == 'U':
                proj = utils.removeDict(proj,pf.PF)
            elif mode == 'S':
                proj = utils.selectDict(proj,res['selected'])
            elif mode == 'N':
                return
            pf.message("Importing symbols: %s" % utils.sortedKeys(proj))
            pf.PF.update(proj)
            listProject()
示例#4
0
def setRender():
    items = [ ('render/%s'%a,getattr(GD.canvas,a),'slider',{'min':0,'max':100,'scale':0.01,'func':getattr(draw,'set_%s'%a)}) for a in [ 'ambient', 'specular', 'emission', 'shininess' ] ]
    print items
    res = draw.askItems(items)
    if res:
        print res
        updateSettings(res,GD.cfg)
示例#5
0
def setOptions():
    options = ['test','debug','uselib','safelib','fastencode','fastfuse']
    items = [ (o,getattr(pyformex.options,o)) for o in options ]
    res = draw.askItems(items)
    if res:
        for o in options:
            setattr(pyformex.options,o,res[o])
示例#6
0
def createMovieInteractive():
    """Create a movie from a saved sequence of images.

    """
    if not image.multisave:
        pf.warning('You need to start multisave mode first!')
        return

    names = image.multisave[0]
    glob = names.glob()

    res = draw.askItems(
        [ _I('files',glob),
          _I('encoder',choices=['mencoder','convert','ffmpeg']),
          _G('Mencoder',[
              _I('fps',10),
              _I('vbirate',800),
              ]),
          _G('Convert',[
              _I('delay',1),
              _I('colors',256),
              ]),
          ],
        enablers = [
            ('encoder','mencoder','Mencoder'),
            ('encoder','convert','Convert'),
          ])
    if not res:
        return

    pf.GUI.setBusy()
    image.createMovie(**res)
    pf.GUI.setBusy(False)
示例#7
0
def setLineWidth():
    """Change the default line width."""
    res = draw.askItems(
        [_I('Line Width',pf.canvas.settings.linewidth)],
        'Choose default line width'
        )
    if res:
        pf.canvas.setLineWidth(res['Line Width'])
示例#8
0
def setOptions():
    options = ['test','debug','uselib','safelib','fastencode']
    options = [ o for o in options if hasattr(GD.options,o) ]
    items = [ (o,getattr(GD.options,o)) for o in options ]
    res = draw.askItems(items)
    if res:
        for o in options:
            setattr(GD.options,o,res[o])
示例#9
0
def setRenderMode():
    from canvas import Canvas
    res = draw.askItems([('render/mode',None,'vradio',{'text':'Render Mode','choices':Canvas.rendermodes})])
    if res:
        rendermode = res['render/mode']
        if hasattr(draw,rendermode):
            getattr(draw,rendermode)()
        updateSettings(res)
示例#10
0
def showpydoc(item=None):
    """Display the pydoc information about topic."""
    if item is None:
        res = draw.askItems([('Item:','')])
        if res:
            item = res['Item:']
    if item:
        catchAndDisplay("pydoc.help('%s')" % item)
示例#11
0
 def editRow():
     row = _table.currentIndex().row()
     scr = pf.cfg['scriptdirs']
     item = scr[row]
     res = draw.askItems([('Label',item[0]),('Path',item[1])])
     if res:
         scr[row] = [res['Label'],res['Path']]
     _table.update()
示例#12
0
 def editRow():
     row = _table.currentIndex().row()
     scr = pf.cfg["scriptdirs"]
     item = scr[row]
     res = draw.askItems([("Label", item[0]), ("Path", item[1])])
     if res:
         scr[row] = [res["Label"], res["Path"]]
     _table.update()
示例#13
0
def setCanvasSize():
    """Save the current viewport size"""
    res = draw.askItems([
        _I('w',pf.canvas.width()),
        _I('h',pf.canvas.height())
        ],'Set Canvas Size'
        )
    if res:
        draw.canvasSize(res['w'],res['h'])
def setTriadeParams():
    try:
        size = GD.canvas.triade.size
        pos = GD.canvas.triade.pos.tolist()
    except:
        size = 1.0
        pos = [0.,0.,0.]
    res = draw.askItems([('size',size),('pos',pos)])
    if res:
        draw.setTriade(True,res['size'],res['pos'])
def setTriadeParams():
    try:
        size = GD.canvas.triade.size
        pos = GD.canvas.triade.pos.tolist()
    except:
        size = 1.0
        pos = [0.0, 0.0, 0.0]
    res = draw.askItems([("size", size), ("pos", pos)])
    if res:
        draw.setTriade(True, res["size"], res["pos"])
示例#16
0
def searchText():
    from widgets import simpleInputItem as _I
    res = draw.askItems([
        _I('pattern','',text='String to grep'),
        _I('options','',text='Options',tooltip="Some cool options: -a (extended search), -i (ignore case), -f (literal string), -e (extended regexp)"),
        ])

    if res:
        out = utils.grepSource(relative=False,quiet=True,**res)
        draw.showText(out,mono=True,modal=False)
示例#17
0
def setOptions():
    options = ['redirect', 'debuglevel', 'rst2html']
    options = [o for o in options if hasattr(pf.options, o)]
    items = [_I(o, getattr(pf.options, o)) for o in options]
    res = draw.askItems(items)
    if res:
        print(res)
        for o in options:
            setattr(pf.options, o, res[o])
            print("Options: %s" % pf.options)
            if o == 'redirect':
                pf.GUI.board.redirect(pf.options.redirect)
示例#18
0
def setOptions():
    options = ['test','uselib','safelib','fastencode']
    options = [ o for o in options if hasattr(pf.options,o) ]
    items = [ (o,getattr(pf.options,o)) for o in options ]
    debug_levels = [ 'All','None' ]
    items.append(('debug',None,'vradio',debug_levels))
    res = draw.askItems(items)
    if res:
        for o in options:
            setattr(pf.options,o,res[o])
            setattr(pf.options,'debug',debug_levels.index(res['debug'])-1)
            print("Options: %s" % pf.options)
示例#19
0
def setOptions():
    options = [ 'redirect','debuglevel','rst2html']
    options = [ o for o in options if hasattr(pf.options,o) ]
    items = [ _I(o,getattr(pf.options,o)) for o in options ]
    res = draw.askItems(items)
    if res:
        print(res)
        for o in options:
            setattr(pf.options,o,res[o])
            print("Options: %s" % pf.options)
            if o == 'redirect':
                pf.GUI.board.redirect(pf.options.redirect)
示例#20
0
def setRender():
    items = [
        (
            "render/%s" % a,
            getattr(GD.canvas, a),
            "slider",
            {"min": 0, "max": 100, "scale": 0.01, "func": getattr(draw, "set_%s" % a)},
        )
        for a in ["ambient", "specular", "emission", "shininess"]
    ]
    res = draw.askItems(items)
    if res:
        updateSettings(res, GD.cfg)
def setTriade():
    try:
        pos = pf.canvas.triade.pos
        siz = pf.canvas.triade.siz
    except:
        pos = 'lb'
        siz = 100
    res = draw.askItems([
        ('triade',True),
        ('pos',pos,'select',{'choices':['lt','lc','lb','ct','cc','cb','rt','rc','rb']}),
        ('size',siz),
        ])
    if res:
        draw.setTriade(res['triade'],res['pos'],res['size'])
示例#22
0
def setTriade():
    try:
        pos = pf.canvas.triade.pos
        siz = pf.canvas.triade.siz
    except:
        pos = 'lb'
        siz = 100
    res = draw.askItems([
        _I('triade',True),
        _I('pos',pos,choices=['lt','lc','lb','ct','cc','cb','rt','rc','rb']),
        _I('size',siz),
        ])
    if res:
        draw.setTriade(res['triade'],res['pos'],res['size'])
示例#23
0
 def runAllApps(self):
     res = draw.askItems([
         ('timeout', True),
         ('random', False),
         ('recursive', True),
         ('count', -1),
     ])
     if not res:
         return
     from toolbar import timeout
     timeout(res['timeout'])
     del res['timeout']
     self.runAll(**res)
     timeout(False)
     print("Finished running all examples")
示例#24
0
def setDebug():
    options = [ o for o in dir(pf.DEBUG) if o[0] != '_' ]
    options.remove('ALL')
    options.remove('NONE')
    values = [ getattr(pf.DEBUG,o) for o in options ]
    items = [ _I(o,bool(pf.options.debuglevel & v)) for o,v in zip(options,values) ]
    res = draw.askItems(items)
    if res:
        print(res)
        debug = 0
        for o,v in zip(options,values):
            if res[o]:
                debug |= v
        print("debuglevel = %s" % debug)
        pf.options.debuglevel = debug
示例#25
0
文件: appMenu.py 项目: dladd/pyFormex
 def runAllApps(self):
     res =draw.askItems([
         ('timeout',True),
         ('random',False),
         ('recursive',True),
         ('count',-1),
         ])
     if not res:
         return
     from toolbar import timeout
     timeout(res['timeout'])
     del res['timeout']
     self.runAll(**res)
     timeout(False)
     print("Finished running all examples")
示例#26
0
def searchText():
    from widgets import simpleInputItem as _I
    res = draw.askItems([
        _I('pattern', '', text='String to grep'),
        _I('options',
           '',
           text='Options',
           tooltip=
           "Some cool options: -a (extended search), -i (ignore case), -f (literal string), -e (extended regexp)"
           ),
    ])

    if res:
        out = utils.grepSource(relative=False, quiet=True, **res)
        draw.showText(out, mono=True, modal=False)
示例#27
0
def setOptions():
    options = ["test", "uselib", "fastencode"]
    options = [o for o in options if hasattr(pf.options, o)]
    items = [I(o, getattr(pf.options, o)) for o in options]
    # currently we only have All or None as debug levels
    debug_levels = ["All", "None"]
    if pf.options.debug:
        debug = "All"
    else:
        debug = "None"
    items.append(I("debug", debug, "vradio", choices=debug_levels))
    res = draw.askItems(items)
    if res:
        for o in options:
            setattr(pf.options, o, res[o])
            setattr(pf.options, "debug", debug_levels.index(res["debug"]) - 1)
            print ("Options: %s" % pf.options)
示例#28
0
def setOptions():
    options = ['test','uselib','safelib','fastencode']
    options = [ o for o in options if hasattr(pf.options,o) ]
    items = [ I(o,getattr(pf.options,o)) for o in options ]
    # currently we only have All or None as debug levels
    debug_levels = [ 'All','None' ]
    if pf.options.debug:
        debug = 'All'
    else:
        debug = 'None'
    items.append(I('debug',debug,'vradio',choices=debug_levels))
    res = draw.askItems(items)
    if res:
        for o in options:
            setattr(pf.options,o,res[o])
            setattr(pf.options,'debug',debug_levels.index(res['debug'])-1)
            print("Options: %s" % pf.options)
示例#29
0
def setOptions():
    options = [ 'debug' ] # Currently No user changeable options ['test']
    options = [ o for o in options if hasattr(pf.options,o) ]
    items = [ I(o,getattr(pf.options,o)) for o in options ]
    ## # currently we only have All or None as debug levels
    ## debug_levels = [ 'All','None' ]
    ## if pf.options.debug:
    ##     debug = 'All'
    ## else:
    ##     debug = 'None'
    ## items.append(I('debug',debug,'vradio',choices=debug_levels))
    res = draw.askItems(items)
    if res:
        print res
        for o in options:
            setattr(pf.options,o,res[o])
            #setattr(pf.options,'debug',debug_levels.index(res['debug'])-1)
            print("Options: %s" % pf.options)
示例#30
0
def setDebug():
    options = [o for o in dir(pf.DEBUG) if o[0] != '_']
    options.remove('ALL')
    options.remove('NONE')
    values = [getattr(pf.DEBUG, o) for o in options]
    items = [
        _I(o, bool(pf.options.debuglevel & v))
        for o, v in zip(options, values)
    ]
    res = draw.askItems(items)
    if res:
        print(res)
        debug = 0
        for o, v in zip(options, values):
            if res[o]:
                debug |= v
        print("debuglevel = %s" % debug)
        pf.options.debuglevel = debug
示例#31
0
def drawOptions(d={}):
    """Set the Drawing options.

    A dictionary may be specified to override the current defaults.
    """
    draw.setDrawOptions(d)
    print(pf.canvas.options)
    res = draw.askItems(store=pf.canvas.options,items=[
        _I('view',choices=['None']+pf.canvas.view_angles.keys(),tooltip="Camera viewing direction"),
        _I('bbox',choices=['auto','last'],tooltip="Automatically focus/zoom on the last drawn object(s)"),
        _I('clear',tooltip="Clear the canvas on each drawing action"),
        _I('shrink',tooltip="Shrink all elements to make their borders better visible"),
        _I('shrink_factor'),
        _I('marksize'),
        ],enablers=[('shrink',True,'shrink_factor')]
    )
    if not res:
        return
    if res['view'] == 'None':
        res['view'] = None
    draw.setDrawOptions(res)
示例#32
0
def exitDialog():
    """Show the exit dialog to the user.

    """
    confirm = pf.cfg['gui/exitconfirm']
    ## print "confirm = %s" % confirm
    ## print "pf.PF.filename = %s" % pf.PF.filename
    ## print "pf.PF.hits = %s" % pf.PF.hits

    if confirm == 'never':
        return True

    if confirm == 'smart' and (pf.PF.filename is None or pf.PF.hits == 0):
        return True

    print("Project variable changes: %s" % pf.PF.hits)
    print("pyFormex globals: %s" % pf.PF.keys())

    save_opts = ['To current project file','Under another name','Do not save']
    res = draw.askItems(
        [ draw._I('info',itemtype='label',value="You have unsaved global variables. What shall I do?"),
          draw._I('save',itemtype='vradio',choices=save_opts,text='Save the current globals'),
          draw._I('reopen',pf.cfg['openlastproj'],text="Reopen the project on next startup"),
          ],
        caption='pyFormex exit dialog')

    if not res:
        # Cancel the exit
        return False

    save = save_opts.index(res['save'])
    if save == 0:
        fileMenu.saveProject()
    elif save == 1:
        fileMenu.saveAsProject()

    if not res['reopen']:
        fileMenu.closeProject(save=False,clear=False)

    return True
示例#33
0
def viewportLayout():
    """Set the viewport layout."""
    directions = [ 'rowwise','columnwise' ]
    if pf.GUI.viewports.rowwise:
        current = directions[0]
    else:
        current = directions[1]
    res = draw.askItems(
        [_I('Number of viewports',len(pf.GUI.viewports.all)),
         _I('Viewport layout direction',current,choices=directions),
         _I('Number of viewports per row/column',pf.GUI.viewports.ncols),
         ],
        'Config Dialog')
    if res:
        pf.debug(res)
        nvps = res['Number of viewports']
        rowwise = res['Viewport layout direction'] == 'rowwise'
        ncols = res['Number of viewports per row/column']
        if rowwise:
            nrows = None
        else:
            nrows = ncols
            ncols = None
        pf.GUI.viewports.changeLayout(nvps,ncols,nrows)
示例#34
0
def setCanvasSize():
    res = draw.askItems([['w',GD.canvas.width()],['h',GD.canvas.height()]])
    GD.canvas.resize(int(res['w']),int(res['h']))
def setClip():
    items = [
        ('near',-2.0,'slider',{'min':-100,'max':100,'scale':0.01,'func': set_near_clip}),
        ]
    res = draw.askItems(items)
示例#36
0
def setPickSize():
    w, h = GD.cfg["pick/size"]
    res = draw.askItems([["w", w], ["h", h]])
    GD.cfg["pick/size"] = (int(res["w"]), int(res["h"]))
示例#37
0
def setPickSize():
    w,h = pf.cfg['pick/size']
    res = draw.askItems([['w',w],['h',h]])
    pf.prefcfg['pick/size'] = (int(res['w']),int(res['h']))