From dfd916f52b0c91064f5a46249490e66280d2ec8d Mon Sep 17 00:00:00 2001 From: alexhroom Date: Tue, 12 Nov 2024 14:30:46 +0000 Subject: [PATCH] review fixes --- rascal2/widgets/project/project.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/rascal2/widgets/project/project.py b/rascal2/widgets/project/project.py index cd947f7..8b37109 100644 --- a/rascal2/widgets/project/project.py +++ b/rascal2/widgets/project/project.py @@ -81,7 +81,7 @@ def create_project_view(self) -> None: absorption_label = QtWidgets.QLabel("Absorption:", self, objectName="boldlabel") self.absorption_checkbox = QtWidgets.QCheckBox() # this is how you make a checkbox read-only but still checkable from inside code... - self.absorption_checkbox.setAttribute(QtCore.Qt.WidgetAttribute.WA_TransparentForMouseEvents) + self.absorption_checkbox.setDisabled(True) settings_layout.addWidget(absorption_label) settings_layout.addWidget(self.absorption_checkbox) @@ -304,23 +304,25 @@ def validate_draft_project(self): layer_attrs.remove("name") layer_attrs.remove("hydrate_with") # ensure all layer parameters have been filled in, and all names are layers that exist + valid_params = [p.name for p in self.draft_project["parameters"]] for i, layer in enumerate(self.draft_project["layers"]): - missing_params = [p for p in layer_attrs if getattr(layer, p) == ""] - invalid_params = [ - (p, v) - for p in layer_attrs - if (v := getattr(layer, p)) not in [p.name for p in self.draft_project["parameters"]] - and p not in missing_params - ] + missing_params = [] + invalid_params = [] + for attr in layer_attrs: + param = getattr(layer, attr) + if param == "": + missing_params.append(attr) + elif param not in valid_params: + invalid_params.append((attr, param)) + if missing_params: noun = "a parameter" if len(missing_params) == 1 else "parameters" msg = f"Layer '{layer.name}' (row {i+1}) is missing {noun}: {', '.join(missing_params)}" errors.append(msg) if invalid_params: noun = "an invalid value" if len(invalid_params) == 1 else "invalid values" - msg = ( - f"Layer '{layer.name}' (row {i+1}) has {noun}: " - f"{', '.join(f'"{v}" for parameter {p}' for p, v in invalid_params)}" + msg = f"Layer '{layer.name}' (row {i+1}) has {noun}: " "{0}".format( + ",\n ".join(f'"{v}" for parameter {p}' for p, v in invalid_params) ) errors.append(msg)