def populate(self, pattern="", validPins=[pin.__name__ for pin in getAllPinClasses()]): for pinClass in getAllPinClasses(): className = pinClass.__name__ if className in validPins: if len(pattern) > 0: if pattern.lower() in className.lower(): self.createEntry(className) else: self.createEntry(className) self.setCurrentRow(0)
def createPropertiesWidget(self, propertiesWidget): baseCategory = CollapsibleFormWidget(headName="Base", modify=True) # name le_name = QLineEdit(self._rawVariable.name) le_name.returnPressed.connect(lambda: self.setName(le_name.text())) baseCategory.addWidget("Name", le_name) # data type cbTypes = EnumComboBox([ pin.__name__ for pin in getAllPinClasses() if pin.IsValuePin() if pin.__name__ != "AnyPin" ]) cbTypes.setCurrentIndex(cbTypes.findText(self.dataType)) cbTypes.setEditable(False) cbTypes.changeCallback.connect(self.setDataType) propertiesWidget.addWidget(baseCategory) # structure type cbStructure = EnumComboBox( [i.name for i in (PinStructure.Single, PinStructure.Array)]) cbStructure.setEditable(False) cbStructure.setCurrentIndex( cbStructure.findText(self._rawVariable.structure.name)) cbStructure.changeCallback.connect(self.onStructureChanged) propertiesWidget.addWidget(baseCategory) baseCategory.addWidget("Type", cbTypes) baseCategory.addWidget("Structure", cbStructure) valueCategory = CollapsibleFormWidget(headName="Value") # current value if self._rawVariable.structure == PinStructure.Single: if not type(self._rawVariable.value) in {list, set, dict, tuple}: def valSetter(x): self._rawVariable.value = x w = createInputWidget( self._rawVariable.dataType, valSetter, getPinDefaultValueByType(self._rawVariable.dataType)) if w: w.setWidgetValue(self._rawVariable.value) w.setObjectName(self._rawVariable.name) valueCategory.addWidget(self._rawVariable.name, w) # access level cb = QComboBox() cb.addItem('public', 0) cb.addItem('private', 1) cb.addItem('protected', 2) def accessLevelChanged(x): self._rawVariable.accessLevel = AccessLevel[x] EditorHistory().saveState("Change variable access level", modify=True) cb.currentTextChanged.connect(accessLevelChanged) cb.setCurrentIndex(self._rawVariable.accessLevel) valueCategory.addWidget('Access level', cb) propertiesWidget.addWidget(valueCategory)
def __init__(self, name): super(convertTo, self).__init__(name) self.input = self.createInputPin("in", 'AnyPin', defaultValue=None) self.output = self.createOutputPin("result", 'AnyPin', defaultValue=None) pinAffects(self.input, self.output) self.input.enableOptions(PinOptions.AllowAny) self.pinTypes = [] for pinClass in getAllPinClasses(): if pinClass.IsValuePin(): self.pinTypes.append(pinClass.__name__) self.bCacheEnabled = False
def __init__(self, var, parent=None): super(VarTypeComboBox, self).__init__(parent) self._bJustSpawned = True self.var = var self.types = [ pin.__name__ for pin in getAllPinClasses() if pin.IsValuePin() ] for i in self.types: self.addItem(i) self.currentIndexChanged.connect(self.onCurrentIndexChanged) self.setCurrentIndex(self.findText(var.dataType)) self._bJustSpawned = False
def __init__(self, editor): super(WPinWidget, self).__init__() self.setupUi(self) self.editor = weakref.ref(editor) self.lePinName.setText('pinName') self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.items = [t.__name__ for t in getAllPinClasses()] self.cbType.clear() for i in self.items: self.cbType.addItem(i) self.cbType.setCurrentIndex(self.cbType.findText('AnyPin'))
def __init__(self, name): super(constant, self).__init__(name) self.input = self.createInputPin("in", 'AnyPin', defaultValue=0.0, structure=PinStructure.Multi, constraint="1", structConstraint="1") self.output = self.createOutputPin("out", 'AnyPin', defaultValue=0.0, structure=PinStructure.Multi, constraint="1", structConstraint="1") self.input.disableOptions(PinOptions.ChangeTypeOnConnection) self.output.disableOptions(PinOptions.ChangeTypeOnConnection) pinAffects(self.input, self.output) self.input.call = self.output.call self.pinTypes = [] for pinClass in getAllPinClasses(): if pinClass.IsValuePin() and pinClass.__name__ != "AnyPin": self.pinTypes.append(pinClass.__name__) self.bCacheEnabled = False
def setTypeFromData(self, data): """Initialize DataType from actual data Iterates all defined Pin and compares type(data) with Pin.internalDataStructure() to find a valid DataType :param data: Actual data to search Pin/dataType from """ for pin in [pin for pin in getAllPinClasses() if pin.IsValuePin()]: pType = pin.internalDataStructure() if type(data) == pType: if pin.__name__ != self.activeDataType: if self.optionEnabled(PinOptions.ChangeTypeOnConnection): traverseConstrainedPins(self, lambda x: self.updateOnConnectionCallback(x, pin.__name__, True, None)) self.owningNode().checkForErrors() break
def __init__(self, name, parent, direction, **kwargs): super(AnyPin, self).__init__(name, parent, direction, **kwargs) self.typeChanged = Signal(str) self.dataTypeBeenSet = Signal() self.setDefaultValue(None) self._free = True self._isAny = True self.super = None self.activeDataType = self.__class__.__name__ # if True, setType and setDefault will work only once self.singleInit = False self.initialized = False self.tempInitialized = False self.changeTypeOnConnection = True self._defaultSupportedDataTypes = self._supportedDataTypes = tuple( [pin.__name__ for pin in getAllPinClasses() if pin.IsValuePin()])
def __init__(self, name): super(constant, self).__init__(name) self.input = self.createInputPin("in", 'AnyPin', structure=PinStructure.Multi, constraint="1", structConstraint="1") self.output = self.createOutputPin("out", 'AnyPin', structure=PinStructure.Multi, constraint="1", structConstraint="1") pinAffects(self.input, self.output) self.input.call = self.output.call self.pinTypes = [] for pinClass in getAllPinClasses(): if pinClass.IsValuePin(): self.pinTypes.append(pinClass.__name__)
def __init__(self, parent=None, validPins=None): super(SelectPinDialog, self).__init__(None) self.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint) self.setWindowTitle("Select pin") self.setWindowIcon(QtGui.QIcon(":/pin.png")) self.resize(QtCore.QSize(400, 300)) self.mainLayout = QtWidgets.QVBoxLayout(self) self.mainLayout.setContentsMargins(2, 2, 2, 2) self.searchBox = QtWidgets.QLineEdit() self.searchBox.setPlaceholderText("search...") self.searchBox.textChanged.connect(self.filterContent) self.mainLayout.addWidget(self.searchBox) if not validPins: validPins = [pin.__name__ for pin in getAllPinClasses()] self.content = _PinsListWidget(validPins=validPins) self.mainLayout.addWidget(self.content) self.content.itemClicked.connect(self.onItemClicked) self.content.returnPressed.connect(self.onReturnPressed) self._result = None
def __init__(self, name, owningNode, direction, **kwargs): """ :param name: Pin name :type name: string :param owningNode: Owning Node :type owningNode: :py:class:`PyFlow.Core.NodeBase.NodeBase` :param direction: PinDirection , can be input or output :type direction: :py:class:`PyFlow.Core.Common.PinDirection` """ super(AnyPin, self).__init__(name, owningNode, direction, **kwargs) self.typeChanged = Signal(str) self.dataTypeBeenSet = Signal() self.setDefaultValue(None) self._isAny = True # if True, setType and setDefault will work only once self.singleInit = False self.checkForErrors = True self.enableOptions(PinOptions.ChangeTypeOnConnection) self._defaultSupportedDataTypes = self._supportedDataTypes = tuple( [pin.__name__ for pin in getAllPinClasses() if pin.IsValuePin()]) self.canChange = True self._super = None self.prevDataType = None self._lastError2 = None
def supportedDataTypes(): """Tuple with all the Defined value Pin Classes """ return tuple([pin.__name__ for pin in getAllPinClasses() if pin.IsValuePin()])
def supportedDataTypes(): return tuple( [pin.__name__ for pin in getAllPinClasses() if pin.IsValuePin()])