Skip to content

Commit

Permalink
Fix/Improve tooltips in the ConfigureGUI (#79)
Browse files Browse the repository at this point in the history
* use the motor signal movement_finished() to update the Axis control displays

* disable configuration controls while the probe drive is moving

* if the status of one axis changes make the other AxisControlWidgets update

* make the drive widget update its display when the configuration is changed

* fix over indent

* move all connected functions to MGWidget.configChanged into the _config_changed_handler() method

* when _update_drive_control_widget() execute _refresh_drive_control() if the drive control widget does not have the valid MG

* change default colors to be more color-blind friendly

* Make sure MGWidget is seeded with a mg name if none is given, and the tooltip is accurately produced

* add tooltips for the MotionBuilder gear btn

* do not false invalidate drive if we are editing an existing motion group
  • Loading branch information
rocco8773 authored Jan 15, 2025
1 parent a85c735 commit 24faecd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
18 changes: 16 additions & 2 deletions bapsf_motion/gui/configure/motion_group_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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("")
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions bapsf_motion/gui/widgets/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 24faecd

Please sign in to comment.