def onShow(self, settings): clearLayout(self.layout) properties = PropertiesWidget() properties.setLockCheckBoxVisible(False) properties.setTearOffCopyVisible(False) groupActions = defaultdict(list) for actionName, variants in InputManager().getData().items(): for action in variants: groupActions[action.group].append(action) for groupName, variants in groupActions.items(): category = CollapsibleFormWidget(headName=groupName) for inputActionVariant in variants: actionWidget = InputActionWidget( inputActionRef=inputActionVariant) actionWidget.setAction(inputActionVariant) category.addWidget(label=inputActionVariant.getName(), widget=actionWidget, maxLabelWidth=150) properties.addWidget(category) category.setCollapsed(True) self.layout.addWidget(properties) spacerItem = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) self.layout.addItem(spacerItem)
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 createInputWidgets ( self,propertiesWidget): inputsCategory = super(UICommentNode, self).createInputWidgets(propertiesWidget) appearanceCategory = CollapsibleFormWidget(headName="Appearance") pb = pyf_ColorSlider(type="int",alpha=True,startColor=list(self.color.getRgbF())) pb.valueChanged.connect(self.updateColor) appearanceCategory.addWidget("Color", pb) propertiesWidget.addWidget(appearanceCategory)
def __init__(self, parent=None): super(GeneralPreferences, self).__init__(parent) self.layout = QVBoxLayout(self) self.layout.setContentsMargins(1, 1, 1, 1) self.layout.setSpacing(2) commonCategory = CollapsibleFormWidget(headName="Common") defaultTempFolder = os.path.join(os.path.expanduser('~'), "PyFlowTemp") defaultTempFolder = os.path.normpath(defaultTempFolder) self.tempFilesDir = QLineEdit(defaultTempFolder) commonCategory.addWidget("TempFilesDir", self.tempFilesDir) self.additionalPackagePaths = QLineEdit("") commonCategory.addWidget("Additional package locations", self.additionalPackagePaths) self.layout.addWidget(commonCategory) self.lePythonEditor = QLineEdit("sublime_text.exe @FILE") commonCategory.addWidget("External text editor", self.lePythonEditor) self.historyDepth = QSpinBox() self.historyDepth.setRange(10, 100) def setHistoryCapacity(): EditorHistory().capacity = self.historyDepth.value() self.historyDepth.editingFinished.connect(setHistoryCapacity) commonCategory.addWidget("History depth", self.historyDepth) self.redirectOutput = QCheckBox(self) commonCategory.addWidget("Redirect output", self.redirectOutput) spacerItem = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) self.layout.addItem(spacerItem)
def createPropertiesWidget(self, propertiesWidget): baseCategory = CollapsibleFormWidget(headName="Base") # name le_name = QLineEdit(self.getName()) le_name.setReadOnly(True) # if self.isRenamable(): le_name.setReadOnly(False) le_name.returnPressed.connect(lambda: self.setName(le_name.text())) baseCategory.addWidget("Name", le_name) # type leType = QLineEdit(self.__class__.__name__) leType.setReadOnly(True) baseCategory.addWidget("Type", leType) # pos le_pos = QLineEdit("{0} x {1}".format(self.pos().x(), self.pos().y())) baseCategory.addWidget("Pos", le_pos) propertiesWidget.addWidget(baseCategory) appearanceCategory = CollapsibleFormWidget(headName="Appearance") pb = QPushButton("...") pb.clicked.connect(lambda: self.onChangeColor(True)) appearanceCategory.addWidget("Color", pb) propertiesWidget.addWidget(appearanceCategory) infoCategory = CollapsibleFormWidget(headName="Info") doc = QTextBrowser() doc.setOpenExternalLinks(True) doc.setHtml(self.description()) infoCategory.addWidget("", doc) propertiesWidget.addWidget(infoCategory)
def createPropertiesWidget(self, propertiesWidget): super(UIStickyNote, self).createPropertiesWidget(propertiesWidget) appearanceCategory = CollapsibleFormWidget(headName="Appearance") pb = pyf_ColorSlider(type="int", alpha=True, startColor=list(self.color.getRgbF())) pb.valueChanged.connect(self.updateColor) appearanceCategory.addWidget("Color", pb) pb = pyf_ColorSlider(type="int", alpha=True, startColor=list(self.labelTextColor.getRgbF())) pb.valueChanged.connect(self.updateTextColor) appearanceCategory.addWidget("TextColor", pb) propertiesWidget.insertWidget(appearanceCategory,1)
def createPropertiesWidget(self, propertiesWidget): self.propertyEditor = weakref.ref(propertiesWidget) baseCategory = CollapsibleFormWidget(headName="Base") le_name = QLineEdit(self.getName()) le_name.setReadOnly(True) baseCategory.addWidget("Name", le_name) leUid = QLineEdit(str(self._rawNode.graph().name)) leUid.setReadOnly(True) baseCategory.addWidget("Owning graph", leUid) text = "{0}".format(self.packageName) if self._rawNode.lib: text += " | {0}".format(self._rawNode.lib) text += " | {0}".format(self._rawNode.__class__.__name__) leType = QLineEdit(text) leType.setReadOnly(True) baseCategory.addWidget("Type", leType) self.propertyEditor().addWidget(baseCategory) self.createInputWidgets(self.propertyEditor()) Info = CollapsibleFormWidget(headName="Info", collapsed=True) doc = QTextBrowser() doc.setOpenExternalLinks(True) doc.setHtml(self.description()) Info.addWidget(widget=doc) self.propertyEditor().addWidget(Info)
def __init__(self, parent=None): super(DemoPrefs, self).__init__(parent) self.layout = QVBoxLayout(self) self.layout.setContentsMargins(1, 1, 1, 1) self.layout.setSpacing(2) demoSection = CollapsibleFormWidget(headName="Demo section") self.exampleProperty = QLineEdit("Property value") demoSection.addWidget("Example property", self.exampleProperty) self.layout.addWidget(demoSection) spacerItem = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) self.layout.addItem(spacerItem)
def __init__(self, parent=None): super(GeneralPreferences, self).__init__(parent) self.layout = QVBoxLayout(self) self.layout.setContentsMargins(1, 1, 1, 1) self.layout.setSpacing(2) commonCategory = CollapsibleFormWidget(headName="Common") self.tempFilesDir = QLineEdit(os.path.expanduser('~/PyFlowTemp')) commonCategory.addWidget("TempFilesDir", self.tempFilesDir) self.layout.addWidget(commonCategory) pythonNodeCategory = CollapsibleFormWidget(headName="Python node") self.lePythonEditor = QLineEdit("notepad.exe @FILE") pythonNodeCategory.addWidget("Editor cmd", self.lePythonEditor) self.layout.addWidget(pythonNodeCategory) spacerItem = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) self.layout.addItem(spacerItem)
def createInputWidgets(self,propertiesWidget): # inputs if len([i for i in self.UIinputs.values()]) != 0: inputsCategory = CollapsibleFormWidget(headName="Inputs") sortedInputs = sorted(self.UIinputs.values(), key=lambda x: x.name) for inp in sortedInputs: if inp.isArray(): # TODO: create list input widget continue dataSetter = inp.call if inp.isExec() else inp.setData w = createInputWidget(inp.dataType, dataSetter, inp.defaultValue()) if w: inp.dataBeenSet.connect(w.setWidgetValueNoSignals) w.blockWidgetSignals(True) w.setWidgetValue(inp.currentData()) w.blockWidgetSignals(False) w.setObjectName(inp.getName()) inputsCategory.addWidget(inp.name, w) if inp.hasConnections(): w.setEnabled(False) propertiesWidget.addWidget(inputsCategory) return inputsCategory
def createPropertiesWidget(self, propertiesWidget): baseCategory = CollapsibleFormWidget(headName="Base") # 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 = VarTypeComboBox(self) baseCategory.addWidget("Type", cbTypes) propertiesWidget.addWidget(baseCategory) valueCategory = CollapsibleFormWidget(headName="Value") # current value 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] cb.currentTextChanged.connect(accessLevelChanged) cb.setCurrentIndex(self._rawVariable.accessLevel) valueCategory.addWidget('Access level', cb) propertiesWidget.addWidget(valueCategory)
def onShow(self, settings): clearLayout(self.layout) editableStyleSheet().loadPresests(THEMES_PATH) properties = PropertiesWidget() properties.lockCheckBox.hide() properties.tearOffCopy.hide() general = CollapsibleFormWidget(headName="General") bg = CollapsibleFormWidget(headName="BackGround") canvas = CollapsibleFormWidget(headName="Canvas") options = inspect.getmembers(editableStyleSheet()) for name, obj in options: if isinstance(obj, QtGui.QColor): inp = pyf_ColorSlider(type="int", alpha=len(list(obj.getRgbF())) == 4, startColor=list(obj.getRgbF())) inp.valueChanged.connect(lambda color, name=name, update=True: editableStyleSheet().setColor(name, color, update)) if name in ["TextColor", "MainColor", "TextSelectedColor", "ButtonsColor"]: general.addWidget(name, inp) elif name in ["InputFieldColor", "BgColor", "BgColorDarker", "BgColorBright", "BorderColor"]: bg.addWidget(name, inp) elif name in ["CanvasBgColor", "CanvastextColor", "CanvasGridColor", "CanvasGridColorDarker"]: canvas.addWidget(name, inp) elif isinstance(obj, list): if name in ["GridSizeFine", "GridSizeHuge"]: inp = pyf_Slider(self) inp.setValue(obj[0]) inp.valueChanged.connect(lambda color, name=name, update=True: editableStyleSheet().setColor(name, color,update) ) elif name in ["DrawNumbers"]: inp = QCheckBox() inp.setChecked(obj[0]) inp.stateChanged.connect(lambda color, name=name, update=True: editableStyleSheet().setColor(name, color,update) ) canvas.addWidget(name, inp) self.selector = QComboBox() for name in editableStyleSheet().presests.keys(): self.selector.addItem(name) if isinstance(settings, str): if settings in editableStyleSheet().presests: self.selector.setCurrentIndex(list(editableStyleSheet().presests.keys()).index(settings)) elif settings and settings.value('Theme_Name'): if settings.value('Theme_Name') in editableStyleSheet().presests: self.selector.setCurrentIndex(list(editableStyleSheet().presests.keys()).index(settings.value('Theme_Name'))) self.layout.addWidget(self.selector) self.selector.activated.connect(self.setPreset) general.setCollapsed(True) bg.setCollapsed(True) canvas.setCollapsed(True) properties.addWidget(general) properties.addWidget(bg) properties.addWidget(canvas) self.layout.addWidget(properties) spacerItem = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) self.layout.addItem(spacerItem) lay = QHBoxLayout() pbSaveTheme = QPushButton("SaveTheme") pbSaveTheme.clicked.connect(self.saveTheme) pbSaveThemeAs = QPushButton("SaveThemeAs") pbSaveThemeAs.clicked.connect(self.saveThemeAs) pbDeleteTheme = QPushButton("RemoveTheme") pbDeleteTheme.clicked.connect(self.deleteTheme) lay.addWidget(pbSaveTheme) lay.addWidget(pbSaveThemeAs) lay.addWidget(pbDeleteTheme) self.layout.addLayout(lay)
def onShow(self, settings): clearLayout(self.layout) editableStyleSheet().loadPresets(THEMES_PATH) properties = PropertiesWidget() properties.setLockCheckBoxVisible(False) properties.setTearOffCopyVisible(False) general = CollapsibleFormWidget(headName="General") bg = CollapsibleFormWidget(headName="BackGround") canvas = CollapsibleFormWidget(headName="Canvas") connections = CollapsibleFormWidget(headName="Connections") lods = CollapsibleFormWidget(headName="LODS") lodMax = None lodWidgets = [] options = inspect.getmembers(editableStyleSheet()) for name, obj in options: if isinstance(obj, QtGui.QColor): inp = pyf_ColorSlider(type="int", alpha=len(list(obj.toTuple())) == 4, startColor=list(obj.toTuple())) inp.valueChanged.connect(lambda color, name=name, update=True: editableStyleSheet().setColor(name, color, update)) if name in ["TextColor", "MainColor", "TextSelectedColor", "ButtonsColor"]: general.addWidget(name, inp) elif name in ["InputFieldColor", "BgColor", "BgColorDarker", "BgColorBright", "BorderColor", "LoggerBgColor"]: bg.addWidget(name, inp) elif name in ["CanvasBgColor", "CanvastextColor", "CanvasGridColor", "CanvasGridColorDarker"]: canvas.addWidget(name, inp) elif isinstance(obj, list): if name in ["GridSizeFine", "GridSizeHuge", "ConnectionRoundness", "ConnectionOffset"]: inp = pyf_Slider(self) inp.setValue(obj[0]) inp.setMinimum(0) inp.setMaximum(1000.0) inp.valueChanged.connect(lambda color, name=name, update=False: editableStyleSheet().setColor(name, color, update)) elif name in ["DrawNumbers", "SetAppStyleSheet","DrawGrid"]: inp = QCheckBox() inp.setChecked(obj[0]) inp.stateChanged.connect(lambda color, name=name, update=True: editableStyleSheet().setColor(name, color, update)) elif name == "ConnectionMode": inp = QComboBox() for i in ConnectionTypes: inp.addItem(i.name) inp.setCurrentIndex(obj[0]) inp.currentIndexChanged.connect(lambda value, name=name, update=False: editableStyleSheet().setColor(name, value, update)) elif name in ["LOD_Number", "NodeSwitch", "ConnectionSwitch", "PinSwitch", "CanvasSwitch"]: inp = pyf_Slider(self, type="int") inp.setValue(obj[0]) if name != "LOD_Number": inp.setMinimum(0) inp.setMaximum(editableStyleSheet().LOD_Number[0]) lodWidgets.append(inp) else: lodMax = inp inp.setMinimum(0) inp.valueChanged.connect(lambda color, name=name, update=False: editableStyleSheet().setColor(name, color, update)) if name in ["ConnectionMode", "ConnectionRoundness","ConnectionOffset"]: connections.addWidget(name, inp) elif name == "SetAppStyleSheet": general.insertWidget(0, name, inp) elif name in ["NodeSwitch", "ConnectionSwitch", "PinSwitch", "CanvasSwitch"]: lods.addWidget(name, inp) elif name == "LOD_Number": lods.insertWidget(0, name, inp) else: canvas.addWidget(name, inp) for lod in lodWidgets: lodMax.valueChanged.connect(lod.setMaximum) self.selector = QComboBox() for name in editableStyleSheet().presets.keys(): self.selector.addItem(name) if self.currTheme is not None: self.selector.setCurrentIndex(self.currTheme) else: if isinstance(settings, str): if settings in editableStyleSheet().presets: self.selector.setCurrentIndex(list(editableStyleSheet().presets.keys()).index(settings)) elif settings and settings.value('Theme_Name'): if settings.value('Theme_Name') in editableStyleSheet().presets: self.selector.setCurrentIndex(list(editableStyleSheet().presets.keys()).index(settings.value('Theme_Name'))) self.currTheme = self.selector.currentIndex() self.layout.addWidget(self.selector) self.selector.activated.connect(self.setPreset) general.setCollapsed(True) bg.setCollapsed(True) canvas.setCollapsed(True) connections.setCollapsed(True) lods.setCollapsed(True) properties.addWidget(general) properties.addWidget(bg) properties.addWidget(canvas) properties.addWidget(connections) properties.addWidget(lods) self.layout.addWidget(properties) spacerItem = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) self.layout.addItem(spacerItem) lay = QHBoxLayout() pbSaveTheme = QPushButton("SaveTheme") pbSaveTheme.clicked.connect(self.saveTheme) pbSaveThemeAs = QPushButton("SaveThemeAs") pbSaveThemeAs.clicked.connect(self.saveThemeAs) pbDeleteTheme = QPushButton("RemoveTheme") pbDeleteTheme.clicked.connect(self.deleteTheme) lay.addWidget(pbSaveTheme) lay.addWidget(pbSaveThemeAs) lay.addWidget(pbDeleteTheme) self.layout.addLayout(lay)
d.setLayout(QtWidgets.QHBoxLayout()) d.layout().addWidget(tree) d.exec_() newOrder = tree.model_to_dict() if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) s = QtWidgets.QScrollArea() sw = SecurityRatingWidget() rootWidget = CollapsibleFormWidget(headName="Settings", noSpacer=True) rootWidget.addWidget("test", QtWidgets.QPushButton("ss")) rootWidget.addWidget("foo", QtWidgets.QPushButton("")) rootWidget.addWidget("bar", QtWidgets.QPushButton("")) rootWidget2 = CollapsibleFormWidget(headName="Test", noSpacer=True) rootWidget2.addWidget("test2", QtWidgets.QPushButton("aa")) sw.addWidget(rootWidget) sw.addWidget(rootWidget2) s.setWidget(sw) s.show() sw.clear() sys.exit(app.exec_())