MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / TclVariables

Class TclVariables

python/internal.py:14–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12clipping_variables = ['nx', 'ny', 'nz', 'dist', 'dist2', 'enable', 'onlydomain', 'notdomain']
13
14class TclVariables:
15 def __init__(self, name, update_cmd, attributes = []):
16 object.__setattr__(self, '_name', name)
17 object.__setattr__(self, '_update_cmd', update_cmd)
18 object.__setattr__(self, '_attributes', attributes)
19
20 # set corresponding variable in tcl and call update_cmd
21 def __setattr__(self, attribute_name, value):
22 if not attribute_name in self._attributes:
23 raise KeyError()
24 tcl_string = 'set '+self._name+'.'+attribute_name+' '+str(value)+'; '+self._update_cmd+';\n'
25 ngsolve.solve.Tcl_Eval(tcl_string)
26 ngsolve.Redraw()
27
28 # return list of possible attributes - for autocompletion
29 def __dir__(self):
30 return list(self.__dict__.keys()) + self._attributes
31
32 # rlcomplete checks existence of attribute with this function
33 def __getattr__(self, name):
34 if name in self.__dict__:
35 return self.__dict__[name]
36
37 if name in self._attributes:
38 return True
39 raise Exception()
40 def add_group( self, name, attributes=[] ):
41 self.__dict__[name] = TclVariables(self._name +'.'+name, self._update_cmd, attributes)
42
43
44visoptions = TclVariables('::visoptions', 'Ng_Vis_Set parameters', visoptions_variables)

Callers 2

add_groupMethod · 0.85
internal.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected