def setParam(self, name, value): """ Set a parameter value :param name: parameter name """ if name.lower() in self.params: BaseComponent.setParam(self, name, value) else: self.model.setParam(name, value)
def setParam(self, name, value): """ Function to set the value of a parameter. Both VolumeCanvas parameters and shape parameters are accessible. Note: if shape parameters are accessed directly from outside VolumeCanvas. The getPr method should be called before evaluating I(q). TODO: implemented a check method to protect against that. @param name: name of the parameter to change @param value: value to give the parameter """ # Lowercase for case insensitivity name = name.lower() # Look for shape access toks = name.split('.') # If a shape identifier was given, look the shape up # in the dictionary if len(toks) > 1: if toks[0] in self.shapes.keys(): # The shape was found, now look for the parameter if toks[1] in self.shapes[toks[0]].params: # The parameter was found, now change it self.shapes[toks[0]].params[toks[1]] = value self._model_changed() else: raise ValueError, "Could not find parameter %s" % name else: raise ValueError, "Could not find shape %s" % toks[0] else: # If we are not accessing the parameters of a # shape, see if the parameter is part of this object BaseComponent.setParam(self, name, value) self._model_changed()
def setParam(self, name, value): """ Function to set the value of a parameter. Both VolumeCanvas parameters and shape parameters are accessible. Note: if shape parameters are accessed directly from outside VolumeCanvas. The getPr method should be called before evaluating I(q). TODO: implemented a check method to protect against that. @param name: name of the parameter to change @param value: value to give the parameter """ # Lowercase for case insensitivity name = name.lower() # Look for shape access toks = name.split('.') # If a shape identifier was given, look the shape up # in the dictionary if len(toks)>1: if toks[0] in self.shapes.keys(): # The shape was found, now look for the parameter if toks[1] in self.shapes[toks[0]].params: # The parameter was found, now change it self.shapes[toks[0]].params[toks[1]] = value self._model_changed() else: raise ValueError, "Could not find parameter %s" % name else: raise ValueError, "Could not find shape %s" % toks[0] else: # If we are not accessing the parameters of a # shape, see if the parameter is part of this object BaseComponent.setParam(self, name, value) self._model_changed()