def askConfigPreferences(items,prefix=None,store=None): """Ask preferences stored in config variables. Items in list should only be keys. store is usually a dictionary, but can be any class that allow the setdefault method for lookup while setting the default, and the store[key]=val syntax for setting the value. If a prefix is given, actual keys will be 'prefix/key'. The current values are retrieved from the store, and the type returned will be in accordance. If no store is specified, the global config pf.cfg is used. This function can be used to change individual values by a simpler interface than the full settings dialog. """ if store is None: store = pf.cfg if prefix: items = [ '%s/%s' % (prefix, i) for i in items ] itemlist = [ _I(i, store[i]) for i in items ] + [ _I('_save_', True, text='Save changes') ] res = widgets.InputDialog(itemlist, 'Config Dialog', pf.GUI).getResults() #pf.debug(res,pf.DEBUG.CONFIG) if res and store==pf.cfg: updateSettings(res) return res
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 = proj.contents() 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 print("Importing symbols: %s" % proj.contents()) pf.PF.update(proj) listProject()
def openglSettings(): dia = None def apply_(): dia.acceptData() canvas.glSettings(dia.results) def close(): dia.close() dia = widgets.InputDialog( caption='OpenGL Settings', items=[ _I('Line Smoothing', 'Off', itemtype='radio', choices=['On', 'Off']), _I('Polygon Mode', None, itemtype='radio', choices=['Fill', 'Line']), _I('Polygon Fill', None, itemtype='radio', choices=['Front and Back', 'Front', 'Back']), _I('Culling', 'Off', itemtype='radio', choices=['On', 'Off']), # These are currently set by the render mode # ('Shading',None,'radio',{'choices':['Smooth','Flat']}), # ('Lighting',None,'radio',{'choices':['On','Off']}), ], actions=[('Done', close), ('Apply', apply_)]) dia.show()
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), ], caption='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)
def multiWebGL(): """Export the current scene as a model in a multiscene WebGL The user is asked for a file name to store the exported model, and after export, whether to load the model in the browser. """ global last_exported_webgl last_exported_webgl = None if draw.the_multiWebGL is None: print("NO CURRENT EXPORT") else: print("CURRENTLY EXPORTED: %s" % draw.the_multiWebGL.scenes) if draw.the_multiWebGL is None: fn = draw.askNewFilename(pf.cfg['workdir'], 'html') if fn: print("Exporting multiscene WebGL to %s" % fn) draw.multiWebGL(fn=fn) print(draw.the_multiWebGL) if draw.the_multiWebGL is not None: res = draw.askItems([ _I('name',draw.the_multiWebGL.name,text='Name of the scene',tooltip='An empty name will skip the export of the current scene'), _I('finish',False,text='Finish the export'), ]) if res['name']: draw.multiWebGL(res['name']) if res['finish']: last_exported_webgl = draw.multiWebGL()
def setCanvasSize(): """Save the current viewport size""" res = draw.askItems( [_I('w', pf.canvas.width()), _I('h', pf.canvas.height())], caption='Set Canvas Size') if res: draw.canvasSize(res['w'], res['h'])
def actorDialog(actorids): """Create an actor dialog for the specified actors (by index) """ from pyformex.gui.draw import _T, _G, _I, askItems print("actorDialog %s" % actorids) actors = [ pf.canvas.actors[i] for i in actorids ] items = [ _T("actor_%s" % i, [ _I('name', str(a.name)), _I('type', str(a.getType()), readonly=True), _I('visible', bool(a.visible)), _I('alpha', float(a.alpha)), _I('objcolor', str(a.objcolor), itemtype='color'), ]) for i, a in zip(actorids, actors) ] res = askItems(items) print(res)
def setTriade(): try: pos = pf.canvas.triade.pos size = pf.canvas.triade.size except: pos = 'lb' size = 50 res = draw.askItems([ _I('triade', True), _I('pos', pos, choices=['lt', 'lc', 'lb', 'ct', 'cc', 'cb', 'rt', 'rc', 'rb']), _I('size', size), ]) if res: draw.setTriade(res['triade'], res['pos'], res['size'])
def createDirsDialog(dircfg): """Create a Dialog to set a list of paths. dircfg is a config variable that is a list of directories. """ _dia=None _table=None mode = dircfg[:-4] if mode == 'app': title = 'Application paths' else: title='Script paths' def insertRow(): ww = widgets.FileDialog(pf.cfg['workdir'], '*', exist=True, dir=True) fn = ww.getFilename() if fn: _table.model().insertRows() _table.model()._data[-1] = [os.path.basename(fn).capitalize(), fn] _table.update() def removeRow(): row = _table.currentIndex().row() _table.model().removeRows(row, 1) _table.update() def moveUp(): row = _table.currentIndex().row() if row > 0: a, b = _table.model()._data[row-1:row+1] _table.model()._data[row-1:row+1] = b, a _table.setFocus() # For some unkown reason, this seems needed to # immediately update the widget _table.update() pf.app.processEvents() def reloadMenu(): from pyformex.gui import appMenu appMenu.reloadMenu(mode=mode) data = [list(c) for c in pf.cfg[dircfg]] _dia = widgets.InputDialog( items = [ _I(dircfg, data, itemtype='table', chead = ['Label', 'Path']), ], actions = [ ('New', insertRow), ('Delete', removeRow), ('Move Up', moveUp), ('OK',), ('Cancel',), ], caption=title) _table = _dia[dircfg].input return _dia
def searchText(): """Search text in pyFormex source files. Asks a pattern from the user and searches for it through all the pyFormex source files. """ from pyformex.gui.draw import _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, **res) draw.showText(out, mono=True, modal=False)
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)
def drawOptions(d={}): """Set the Drawing options. A dictionary may be specified to override the current defaults. """ draw.setDrawOptions(d) print(pf.canvas.drawoptions) res = draw.askItems( store=pf.canvas.drawoptions, 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)
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)
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
def searchIndex(): """Search text in pyFormex refman index. Asks a pattern from the user and searches for it the index of the local pyFormex documentation. Displays the results in the browser. """ from pyformex.gui.draw import _I res = draw.askItems([ _I('text', '', text='String to search'), ]) if res: print( "file://%s/doc/html/search.html?q=%s&check_keywords=yes&area=default" % (pf.cfg['pyformexdir'], res['text'])) showURL( "file://%s/doc/html/search.html?q=%s&check_keywords=yes&area=default" % (pf.cfg['pyformexdir'], res['text']))
def objectItems(obj): if not isinstance(obj, GeomActor): return [] items = [ # _I('name', obj.name), _I('visible', True, func=set_attr, data=obj), _I('opak', obj.opak, func=set_attr, data=obj), ] if 'objectColor' in obj: items.append( _I('objectColor', obj.objectColor, itemtype='color', min=0.0, max=100.0, scale=0.01, func=set_attr, data=obj)) if 'objectBkColor' in obj: items.append( _I('objectBkColor', obj.objectBkColor, itemtype='color', min=0.0, max=100.0, scale=0.01, func=set_attr, data=obj)) if 'alpha' in obj: items.append( _I('alpha', obj.alpha, itemtype='fslider', min=0.0, max=100.0, scale=0.01, func=set_attr, data=obj)) if 'pointsize' in obj: items.append( _I('pointsize', obj.marksize, itemtype='fslider', min=0.0, max=100.0, scale=0.1, func=set_attr, data=obj)) return items
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'])
def canvasSettings(): """Interactively change the canvas settings. Creates a dialog to change the canvasSettings of the current or any other viewport """ dia = None def close(): dia.close() def getVp(vp): """Return the vp corresponding with a vp choice string""" if vp == 'current': vp = pf.GUI.viewports.current elif vp == 'focus': vp = pf.canvas else: vp = pf.GUI.viewports.all[int(vp)] return vp def accept(save=False): dia.acceptData() res = dia.results vp = getVp(res['viewport']) pf.debug( "Changing Canvas settings for viewport %s to:\n%s" % (pf.GUI.viewports.viewIndex(vp), res), pf.DEBUG.CANVAS) pf.canvas.settings.update(res, strict=False) pf.canvas.redrawAll() pf.canvas.update() if save: res = utils.prefixDict(res, 'canvas/') print(res) res['_save_'] = save del res['canvas/viewport'] prefMenu.updateSettings(res) def acceptAndSave(): accept(save=True) def changeViewport(vp): if vp == 'current': vp = pf.GUI.viewports.current elif vp == 'focus': vp = pf.canvas else: vp = pf.GUI.viewports.all[int(vp)] dia.updateData(vp.settings) canv = pf.canvas vp = pf.GUI.viewports pf.debug("Focus: %s; Current: %s" % (canv, vp), pf.DEBUG.CANVAS) s = canv.settings dia = widgets.InputDialog( caption='Canvas Settings', store=canv.settings, items=[ _I('viewport', choices=['focus', 'current'] + [str(i) for i in range(len(pf.GUI.viewports.all))], onselect=changeViewport), _I('pointsize', ), _I('linewidth', ), _I('linestipple', ), _I('fgcolor', itemtype='color'), _I('slcolor', itemtype='color'), _I('smooth'), _I('fill'), _I('lighting'), _I('culling'), _I('alphablend'), _I('transparency', min=0.0, max=1.0), _I('avgnormals', ), ], enablers=[ ('alphablend', ('transparency')), ], actions=[ ('Close', close), ('Apply and Save', acceptAndSave), ('Apply', accept), ], ) #dia.resize(800,400) dia.show()
def setBgColor(): """Interactively set the viewport background colors.""" global bgcolor_dialog from pyformex.opengl.sanitize import saneColorArray from numpy import resize from pyformex.opengl import colors import os bgmodes = pf.canvas.settings.bgcolor_modes mode = pf.canvas.settings.bgmode color = saneColorArray(pf.canvas.settings.bgcolor, (4, )) color = resize(color, (4, 3)) cur = pf.canvas.settings.bgimage showimage = os.path.exists(cur) if not showimage: cur = pf.cfg['gui/splash'] viewer = widgets.ImageView(cur, maxheight=200) def changeColor(field): bgcolor_dialog.acceptData() res = bgcolor_dialog.results if res: setBackground(**res) bgcolor_dialog = widgets.InputDialog( [ _I('mode', mode, choices=bgmodes), _I('color1', color[0], itemtype='color', func=changeColor, text='Background color 1 (Bottom Left)'), _I('color2', color[1], itemtype='color', func=changeColor, text='Background color 2 (Bottom Right)'), _I('color3', color[2], itemtype='color', func=changeColor, text='Background color 3 (Top Right)'), _I('color4', color[3], itemtype='color', func=changeColor, text='Background color 4 (Top Left'), _I('showimage', showimage, text='Show background image'), _I('image', cur, text='Background image', itemtype='filename', filter='img', exist=True, preview=viewer), viewer, _I('_save_', False, text='Save as default'), ], caption='Config Dialog', enablers=[ ('mode', 'vertical', 'color4'), ('mode', 'horizontal', 'color2'), ('mode', 'full', 'color2', 'color3', 'color4'), ('showimage', True, 'image'), #('mode', 'solid', '_save_'), ]) res = bgcolor_dialog.getResults() if res: setBackground(**res)
def settings(): """Interactively change the pyformex settings. Creates a dialog to change (most of) the pyformex user configuration. To change the canvas setttings, use viewportMenu.canvasSettings. """ from pyformex.opengl import canvas from pyformex import plugins from pyformex import sendmail from pyformex.elements import elementTypes dia = None _actionbuttons = [ 'play', 'rerun', 'step', 'continue', 'stop', 'edit', 'info' ] gui_console_options = { 'b':'Message board only','c':'Console only', 'bc':'Message board and Console' } def close(): dia.close() def accept(save=False): dia.acceptData() res = dia.results res['_save_'] = save ok_plugins = utils.subDict(res, '_plugins/') res['gui/console'] = utils.inverseDict(gui_console_options)[res['gui/console']] res['gui/plugins'] = [ p for p in ok_plugins if ok_plugins[p]] res['gui/actionbuttons'] = [ t for t in _actionbuttons if res['_gui/%sbutton'%t ] ] if res['webgl/script'] == 'custom': res['webgl/script'] = res['_webgl_script'] if res['webgl/guiscript'] == 'custom': res['webgl/guiscript'] = res['_webgl_guiscript'] updateSettings(res) plugins.loadConfiguredPlugins() def acceptAndSave(): accept(save=True) def autoSettings(keylist): return [_I(k, pf.cfg[k]) for k in keylist] def changeDirs(dircfg): """dircfg is a config variable that is a list of dirs""" setDirs(dircfg) dia.updateData({dircfg:pf.cfg[dircfg]}) def changeScriptDirs(): changeDirs('scriptdirs') def changeAppDirs(): changeDirs('appdirs') enablers = [] mouse_settings = autoSettings(['gui/rotfactor', 'gui/panfactor', 'gui/zoomfactor', 'gui/autozoomfactor', 'gui/dynazoom', 'gui/wheelzoom']) # Use _ to avoid adding these items in the config plugin_items = [ _I('_plugins/'+name, name in pf.cfg['gui/plugins'], text=text) for name, text in plugins.pluginMenus() ] bindings_choices = ['any', 'PySide', 'PyQt4'] bindings_current = pf.cfg['gui/bindings'] appearance = [ _I('gui/style', pf.app.currentStyle(), choices=pf.app.getStyles()), _I('gui/font', pf.app.font().toString(), 'font'), ] toolbartip = "Currently, changing the toolbar position will only be in effect when you restart pyFormex" toolbars = [ _I('gui/%s'%t, pf.cfg['gui/%s'%t], text=getattr(pf.GUI, t).windowTitle(), choices=['left', 'right', 'top', 'bottom'], itemtype='radio', tooltip=toolbartip) for t in [ 'camerabar', 'modebar', 'viewbar' ] ] # Use _ to avoid adding these items in the config actionbuttons = [ _I('_gui/%sbutton'%t, t in pf.cfg['gui/actionbuttons'], text="%s Button" % t.capitalize()) for t in _actionbuttons ] # Make sure splash image exists cur = pf.cfg['gui/splash'] if not os.path.exists(cur): pf.cfg['gui/splash'] = cur = pf.refcfg['gui/splash'] splashviewer = widgets.ImageView(cur, maxheight=200) mail_settings = [ _I('mail/sender', pf.cfg.get('mail/sender', sendmail.mail), text="My mail address"), _I('mail/server', pf.cfg.get('mail/server', 'localhost'), text="Outgoing mail server") ] scripts = [ pf.cfg['webgl/script'], # "https:///fewgl-0.2.js", # "file://"+os.path.join(pf.cfg['datadir'],'fewgl.js'), ] if pf.installtype == 'G': fewgl_dir = os.path.join(pf.parentdir, "fewgl") if os.path.exists(fewgl_dir): scripts += [ "file://"+os.path.join(fewgl_dir,f) for f in ['fewgl.js','fewgl_debug.js'] ] scripts.append('custom') guiscripts = [ pf.cfg['webgl/guiscript'], # "https://net.feops.com/public/webgl/xtk_xdat.gui.js", # "file://"+os.path.join(pf.cfg['datadir'],'xtk_xdat.js'), ] guiscripts.append('custom') webgl_settings = [ _I('webgl/script', pf.cfg['webgl/script'], text='WebGL base script', choices=scripts), _I('_webgl_script', '', text='URL for local WebGL base script', itemtype='filename', filter='js', exist=True), _I('webgl/guiscript', pf.cfg['webgl/guiscript'], text='GUI base script', choices=guiscripts), _I('_webgl_guiscript', '', text='URL for local GUI base script'), _I('webgl/autogui', pf.cfg['webgl/autogui'], text='Always add a standard GUI'), _I('webgl/devel', pf.cfg['webgl/devel'], text='Use the pyFormex source WebGL script'), _I('webgl/devpath', pf.cfg['webgl/devpath'], text='Path to the pyFormex source WebGL script'), ] enablers.extend([ ('webgl/script', 'custom', '_webgl_script'), ('webgl/guiscript', 'custom', '_webgl_guiscript'), ('webgl/devel', True, 'webgl/devpath'), ]) dia = widgets.InputDialog( caption='pyFormex Settings', store=pf.cfg, items=[ _T('General', [ _I('syspath', tooltip="If you need to import modules from a non-standard path, you can supply additional paths to search here."), _I('editor', tooltip="The command to be used to edit a script file. The command will be executed with the path to the script file as argument."), _I('viewer', tooltip="The command to be used to view an HTML file. The command will be executed with the path to the HTML file as argument."), _I('browser', tooltip="The command to be used to browse the internet. The command will be executed with an URL as argument."), _I('help/docs'), _I('autorun', text='Startup script', tooltip='This script will automatically be run at pyFormex startup'), _I('scriptdirs', text='Script Paths', tooltip='pyFormex will look for scripts in these directories', buttons=[('Edit', changeScriptDirs)]), _I('appdirs', text='Applicationt Paths', tooltip='pyFormex will look for applications in these directories', buttons=[('Edit', changeAppDirs)]), _I('autoglobals', text='Auto Globals', tooltip='If checked, global Application variables of any Geometry type will automatically be copied to the pyFormex global variable dictionary (PF), and thus become available in the GUI'), _I('showapploaderrors', text='Show Application Load Error Traceback', tooltip='If checked, a traceback of exceptions occurring at Application Load time will be output. If unchecked, such exceptions will be suppressed, and the application will not run.'), _I('loadcurproj', text="Reload last project on startup"), _I('check_print', text="Check scripts for the use of the print statement"), _I('plot2d', text="Prefered 2D plot library", choices=['gnuplot', 'matplotlib']), _I('commands', text='Use commands module instead of subprocess', tooltip="If checked, pyFormex will use the Python 'commands' module for the execution of external commands. The default (unchecked) is to use the 'subprocess' module. If you notice a lot of command failures, or even hangups, you may want to switch."), ], ), _T('Startup', [ _I('_info_01_', 'The settings on this page will only become active after restarting pyFormex', itemtype='info'), _I('gui/bindings', bindings_current, choices=bindings_choices, tooltip="The Python bindings for the Qt4 library"), #_I('gui/interpreter',interpreter_current,choices=interpreter_choices,tooltip="The Python interpreter to use for the message board"), _I('gui/splash', text='Splash image', itemtype='filename', filter='img', exist=True, preview=splashviewer), splashviewer, ]), _T('GUI', [ _G('Appearance', appearance), _G('Components', toolbars+actionbuttons+[ _I('gui/console', gui_console_options[pf.cfg['gui/console']], itemtype='hradio', choices=gui_console_options.values(), text="Board"), _I('gui/redirect', pf.cfg['gui/redirect']), _I('gui/coordsbox'), _I('gui/showfocus', pf.cfg['gui/showfocus']), _I('gui/runalloption', pf.cfg['gui/runalloption']), _I('gui/timeoutbutton', pf.cfg['gui/timeoutbutton']), _I('gui/timeoutvalue', pf.cfg['gui/timeoutvalue']), _I('gui/easter_egg', pf.cfg['gui/easter_egg']), ], ), ]), _T('Canvas', [ _I('_not_active_', 'The canvas settings can be set from the Viewport Menu', itemtype='info', text=''), ]), _T('Drawing', [ _I('draw/rendermode', pf.cfg['draw/rendermode'], choices=canvas.CanvasSettings.RenderProfiles), _I('draw/wait', pf.cfg['draw/wait']), _I('draw/picksize', pf.cfg['draw/picksize']), _I('draw/disable_depth_test', pf.cfg['draw/disable_depth_test'], text='Disable depth testing for transparent actors'), _I('render/avgnormaltreshold', pf.cfg['render/avgnormaltreshold']), _I('_info_00_', itemtype='info', text='Changes to the options below will only become effective after restarting pyFormex!'), _I('draw/quadline', text='Draw as quadratic lines', itemtype='list', check=True, choices=elementTypes(1), tooltip='Line elements checked here will be drawn as quadratic lines whenever possible.'), _I('draw/quadsurf', text='Draw as quadratic surfaces', itemtype='list', check=True, choices=elementTypes(2)+elementTypes(3), tooltip='Surface and volume elements checked here will be drawn as quadratic surfaces whenever possible.'), ]), _T('Mouse', mouse_settings), _T('Plugins', plugin_items), _T('WebGL', webgl_settings), _T('Environment', [ _G('Mail', mail_settings), # _G('Jobs',jobs_settings), ]), ], enablers=enablers, actions=[ ('Close', close), ('Accept and Save', acceptAndSave), ('Accept', accept), ], ) #dia.resize(800,400) dia.show()
def autoSettings(keylist): return [_I(k, pf.cfg[k]) for k in keylist]
def createDialog(): matnames = pf.GUI.materials.keys() mat = vp.material print("createDialog: %s" % vp.settings.lighting) #light0 = {'enabled':True,'ambient':0.0,'diffuse':0.6,'specular':0.4,'position':(1., 1., 2., 0.)} light_items = [] for i in range(4): name = 'light%s' % i light = pf.cfg['light/%s'%name] items = _T(name, [ _I("enabled", text="Enabled", value=light['enabled']), _I("ambient", text="Ambient", value=light['ambient'], itemtype='color', func=changeLight), _I("diffuse", text="Diffuse", value=light['diffuse'], itemtype='color', func=changeLight), _I("specular", text="Specular", value=light['specular'], itemtype='color', func=changeLight), _I("position", text="Position", value=light['position'][:3], itemtype='point'), ]) light_items.append(items) items = [ _I('render/mode', vp.rendermode, text='Rendering Mode', itemtype='select', choices=draw.renderModes()),#,onselect=enableLightParams), _I('render/lighting', vp.settings.lighting, text='Use Lighting'), _I('render/ambient', vp.lightprof.ambient, itemtype='slider', min=0, max=100, scale=0.01, func=set_render_value, text='Global Ambient Lighting'), _G('light', text='Lights', items=light_items), _I('render/material', vp.material.name, text='Material', choices=matnames, onselect=updateLightParams), _G('material', text='Material Parameters', items=[ _I(a, text=a, value=getattr(mat, a), itemtype='slider', min=0, max=100, scale=0.01, func=set_mat_value) for a in [ 'ambient', 'diffuse', 'specular', 'emission'] ] + [ _I(a, text=a, value=getattr(mat, a), itemtype='slider', min=1, max=128, scale=1., func=set_mat_value) for a in ['shininess'] ]), ] enablers = [ ('render/lighting', True, 'render/ambient', 'render/material', 'material'), ] dia = widgets.InputDialog( caption='pyFormex Settings', enablers = enablers, #store=pf.cfg, items=items, #prefix='render/', autoprefix=True, actions=[ ('Close', close), ('Apply and Save', acceptAndSave), ('Apply', accept), ] ) enableLightParams(vp.rendermode) return dia