From 00c45b2bcfe45c4fb556a6a8a9098d509fb8c524 Mon Sep 17 00:00:00 2001 From: wyzula-jan Date: Thu, 12 Mar 2026 23:08:44 +0100 Subject: [PATCH] fix(gui): submit button do not block if fails --- .../bec_widgets/widgets/xray_eye/x_ray_eye.py | 55 +++++++++---------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/csaxs_bec/bec_widgets/widgets/xray_eye/x_ray_eye.py b/csaxs_bec/bec_widgets/widgets/xray_eye/x_ray_eye.py index da71896..342e206 100644 --- a/csaxs_bec/bec_widgets/widgets/xray_eye/x_ray_eye.py +++ b/csaxs_bec/bec_widgets/widgets/xray_eye/x_ray_eye.py @@ -521,38 +521,35 @@ class XRayEye(BECWidget, QWidget): @SafeSlot() def submit(self): """Execute submit action by submit button.""" - print("submit pushed") self.submit_button.blockSignals(True) - if self.roi_manager.single_active_roi is None: - logger.warning("No active ROI") - return - roi_coordinates = self.roi_manager.single_active_roi.get_coordinates() - roi_center_x = roi_coordinates["center_x"] - roi_center_y = roi_coordinates["center_y"] - # Case of rectangular ROI - if isinstance(self.roi_manager.single_active_roi, RectangularROI): - roi_width = roi_coordinates["width"] - roi_height = roi_coordinates["height"] - elif isinstance(self.roi_manager.single_active_roi, CircularROI): - roi_width = roi_coordinates["diameter"] - roi_height = roi_coordinates["radius"] - else: - logger.warning("Unsupported ROI type for submit action.") - return + try: + if self.roi_manager.single_active_roi is None: + logger.warning("No active ROI") + return + roi_coordinates = self.roi_manager.single_active_roi.get_coordinates() + roi_center_x = roi_coordinates["center_x"] + roi_center_y = roi_coordinates["center_y"] + # Case of rectangular ROI + if isinstance(self.roi_manager.single_active_roi, RectangularROI): + roi_width = roi_coordinates["width"] + roi_height = roi_coordinates["height"] + elif isinstance(self.roi_manager.single_active_roi, CircularROI): + roi_width = roi_coordinates["diameter"] + roi_height = roi_coordinates["radius"] + else: + logger.warning("Unsupported ROI type for submit action.") + return - print( - f"current roi: x:{roi_center_x}, y:{roi_center_y}, w:{roi_width},h:{roi_height}" - ) # TODO remove when will be not needed for debugging - # submit roi coordinates - step = int(self.dev.omny_xray_gui.step.read().get("omny_xray_gui_step").get("value")) + # submit roi coordinates + step = int(self.dev.omny_xray_gui.step.read().get("omny_xray_gui_step").get("value")) - xval_x = getattr(self.dev.omny_xray_gui, f"xval_x_{step}").set(roi_center_x) - xval_y = getattr(self.dev.omny_xray_gui, f"yval_y_{step}").set(roi_center_y) - width_x = getattr(self.dev.omny_xray_gui, f"width_x_{step}").set(roi_width) - width_y = getattr(self.dev.omny_xray_gui, f"width_y_{step}").set(roi_height) - self.dev.omny_xray_gui.submit.set(1) - print("submit done") - self.submit_button.blockSignals(False) + getattr(self.dev.omny_xray_gui, f"xval_x_{step}").set(roi_center_x) + getattr(self.dev.omny_xray_gui, f"yval_y_{step}").set(roi_center_y) + getattr(self.dev.omny_xray_gui, f"width_x_{step}").set(roi_width) + getattr(self.dev.omny_xray_gui, f"width_y_{step}").set(roi_height) + self.dev.omny_xray_gui.submit.set(1) + finally: + self.submit_button.blockSignals(False) def cleanup(self): """Cleanup connections on widget close -> disconnect slots and stop live mode of camera."""