def setInput(self, **args): """Set the values on input terminals. For most nodes, this will happen automatically through Terminal.inputChanged. This is normally only used for nodes with no connected inputs.""" changed = False for k, v in args.iteritems(): term = self._inputs[k] oldVal = term.value() if not eq(oldVal, v): changed = True term.setValue(v, process=False) if changed and '_updatesHandled_' not in args: self.update()
def recolor(self, color=None, recurse=True): if color is None: if not self.isConnected(): ## disconnected terminals are black color = QtGui.QColor(0,0,0) elif self.isInput() and not self.hasInput(): ## input terminal with no connected output terminals color = QtGui.QColor(200,200,0) elif self._value is None or eq(self._value, {}): ## terminal is connected but has no data (possibly due to processing error) color = QtGui.QColor(255,255,255) elif self.valueIsAcceptable() is None: ## terminal has data, but it is unknown if the data is ok color = QtGui.QColor(200, 200, 0) elif self.valueIsAcceptable() is True: ## terminal has good input, all ok color = QtGui.QColor(0, 200, 0) else: ## terminal has bad input color = QtGui.QColor(200, 0, 0) self.graphicsItem().setBrush(QtGui.QBrush(color)) if recurse: for t in self.connections(): t.recolor(color, recurse=False)
def setValue(self, val, process=True): """If this is a single-value terminal, val should be a single value. If this is a multi-value terminal, val should be a dict of terminal:value pairs""" if not self.isMultiValue(): if eq(val, self._value): return self._value = val else: if val is not None: self._value.update(val) self.setValueAcceptable(None) ## by default, input values are 'unchecked' until Node.update(). if self.isInput() and process: self.node().update() ## Let the flowchart handle this. #if self.isOutput(): #for c in self.connections(): #if c.isInput(): #c.inputChanged(self) self.recolor()
def setValue(self, val, process=True): """If this is a single-value terminal, val should be a single value. If this is a multi-value terminal, val should be a dict of terminal:value pairs""" if not self.isMultiValue(): if eq(val, self._value): return self._value = val else: if val is not None: self._value.update(val) self.setValueAcceptable( None ) ## by default, input values are 'unchecked' until Node.update(). if self.isInput() and process: self.node().update() ## Let the flowchart handle this. #if self.isOutput(): #for c in self.connections(): #if c.isInput(): #c.inputChanged(self) self.recolor()
def recolor(self, color=None, recurse=True): if color is None: if not self.isConnected(): ## disconnected terminals are black color = QtGui.QColor(0, 0, 0) elif self.isInput() and not self.hasInput( ): ## input terminal with no connected output terminals color = QtGui.QColor(200, 200, 0) elif self._value is None or eq( self._value, {} ): ## terminal is connected but has no data (possibly due to processing error) color = QtGui.QColor(255, 255, 255) elif self.valueIsAcceptable( ) is None: ## terminal has data, but it is unknown if the data is ok color = QtGui.QColor(200, 200, 0) elif self.valueIsAcceptable( ) is True: ## terminal has good input, all ok color = QtGui.QColor(0, 200, 0) else: ## terminal has bad input color = QtGui.QColor(200, 0, 0) self.graphicsItem().setBrush(QtGui.QBrush(color)) if recurse: for t in self.connections(): t.recolor(color, recurse=False)