diff --git a/bapsf_motion/gui/configure/motion_group_widget.py b/bapsf_motion/gui/configure/motion_group_widget.py index 6d1886e7..29542e5a 100644 --- a/bapsf_motion/gui/configure/motion_group_widget.py +++ b/bapsf_motion/gui/configure/motion_group_widget.py @@ -586,6 +586,10 @@ def __init__( deployed_ips = [] if isinstance(self._parent.rm, RunManager): for mg in self._parent.rm.mgs.values(): + if dict_equal(mg_config, mg.config): + # assume we are editing an existing motion group + continue + deployed_mg_names.append(mg.config["name"]) for axis in mg.drive.axes: @@ -788,6 +792,11 @@ def __init__( self._initial_mg_config = _deepcopy_dict(self._mg_config) + if "name" not in self._mg_config or self._mg_config["name"] == "": + self._mg_config["name"] = "A New MG" + self.logger.info(f"starting _mg_config: {self._mg_config}") + self._update_mg_name_widget() + self._spawn_motion_group() self._refresh_drive_control() @@ -1333,7 +1342,6 @@ def mg_config(self) -> Union[Dict[str, Any], "MotionGroupConfig"]: return self._mg_config elif self._mg_config is None: name = self.mg_name_widget.text() - name = "A New MG" if name == "" else name self._mg_config = {"name": name} return self._mg_config @@ -1501,12 +1509,17 @@ def _validate_motion_group(self): if not isinstance(self.mg.mb, MotionBuilder): self.mb_btn.set_invalid() + self.mb_btn.setToolTip("Motion space needs to be defined.") self.done_btn.setEnabled(False) else: if "layer" not in self.mg.mb.config: self.mb_btn.set_invalid() + self.mb_btn.setToolTip( + "A point layer needs to be defined to generate a motion list." + ) else: self.mb_btn.set_valid() + self.mb_btn.setToolTip("") if not isinstance(self.mg.transform, BaseTransform): self.transform_btn.set_invalid() @@ -1529,8 +1542,8 @@ def _validate_motion_group(self): self.done_btn.setEnabled(False) def _validate_motion_group_name(self) -> bool: - self.logger.info("Validating motion group name") mg_name = self.mg_name_widget.text() + self.logger.info(f"Validating motion group name '{mg_name}'.") # clear previous tooltips and actions self.mg_name_widget.setToolTip("") @@ -1570,6 +1583,7 @@ def _validate_drive(self) -> bool: self.mb_dropdown.setEnabled(False) self.mb_btn.setEnabled(False) self.mb_btn.set_invalid() + self.mb_btn.setToolTip("Motion space needs to be defined.") self.transform_dropdown.setEnabled(False) self.transform_btn.setEnabled(False) diff --git a/bapsf_motion/gui/widgets/buttons.py b/bapsf_motion/gui/widgets/buttons.py index 47634e92..2d0dfec0 100644 --- a/bapsf_motion/gui/widgets/buttons.py +++ b/bapsf_motion/gui/widgets/buttons.py @@ -203,8 +203,10 @@ def __init__(self, color: str = "#2980b9", parent=None): class GearValidButton(StyleButton): def __init__(self, parent=None): - self._valid_color = "#499C54" # rgb(14, 212, 0) - self._invalid_color = "#C75450" # rgb(13, 88, 0) + # self._valid_color = "#499C54" # rgb(14, 212, 0) + # self._invalid_color = "#C75450" # rgb(13, 88, 0) + self._valid_color = "#3498DB" # rgb(52, 152, 219) blue + self._invalid_color = "#FF5733" # rgb(242, 94, 62) orange self._valid_icon = qta.icon("fa.gear", color=self._valid_color) self._invalid_icon = qta.icon("fa.gear", color=self._invalid_color)