diff --git a/csaxs_bec/bec_widgets/widgets/tomo_params/tomo_params.py b/csaxs_bec/bec_widgets/widgets/tomo_params/tomo_params.py index cd064641..984a8ee7 100644 --- a/csaxs_bec/bec_widgets/widgets/tomo_params/tomo_params.py +++ b/csaxs_bec/bec_widgets/widgets/tomo_params/tomo_params.py @@ -528,7 +528,9 @@ class OMNY_TomoParams(BECWidget, QWidget): common_form, "ptycho_reconstruct_foldername", "Reconstruct folder" ), "manual_shift": lambda: self._build_double_group( - common_form, self._profile["manual_shift_fields"] + common_form, + self._profile["manual_shift_fields"], + help_texts=self._profile.get("manual_shift_help"), ), "piezo_range": lambda: self._build_double_group( common_form, self._profile["piezo_range_fields"] @@ -572,10 +574,16 @@ class OMNY_TomoParams(BECWidget, QWidget): return box def _build_double_group( - self, form: QFormLayout, fields: list[tuple[str, str, float, float, int]] + self, + form: QFormLayout, + fields: list[tuple[str, str, float, float, int]], + help_texts: dict[str, str] | None = None, ) -> None: for key, label, min_, max_, decimals in fields: - self._add_double(form, key, label, min_=min_, max_=max_, decimals=decimals) + help_text = help_texts.get(key) if help_texts else None + self._add_double( + form, key, label, min_=min_, max_=max_, decimals=decimals, help_text=help_text + ) def _build_int_group(self, form: QFormLayout, fields: list[tuple[str, str, int, int]]) -> None: for key, label, min_, max_ in fields: @@ -626,7 +634,9 @@ class OMNY_TomoParams(BECWidget, QWidget): form.addRow(header_row) for key, label, min_, max_, decimals, _axis in self._profile["offset_fields"]: self._add_double(form, key, label, min_=min_, max_=max_, decimals=decimals) - self._build_double_group(form, self._profile["manual_shift_fields"]) + self._build_double_group( + form, self._profile["manual_shift_fields"], help_texts=self._profile.get("manual_shift_help") + ) def _show_offsets_help(self) -> None: QMessageBox.information( @@ -857,14 +867,36 @@ class OMNY_TomoParams(BECWidget, QWidget): # ── widget factory helpers ──────────────────────────────────────────────── def _add_double( - self, form: QFormLayout, key: str, label: str, min_: float, max_: float, decimals: int + self, + form: QFormLayout, + key: str, + label: str, + min_: float, + max_: float, + decimals: int, + help_text: str | None = None, ) -> QDoubleSpinBox: w = QDoubleSpinBox() w.setDecimals(decimals) w.setRange(min_, max_) w.setEnabled(False) self._pw[key] = w - form.addRow(f"{label}:", w) + if help_text is None: + form.addRow(f"{label}:", w) + else: + # same "?" help-button pattern as _build_offsets_section/ + # _build_fermat_asymmetry_row -- a per-field popup instead of a + # per-group one. + row = QHBoxLayout() + row.addWidget(w, stretch=1) + btn_help = QPushButton("?") + btn_help.setFixedWidth(24) + btn_help.setToolTip(f"What does {label} do?") + btn_help.clicked.connect( + lambda: QMessageBox.information(self, label, help_text) + ) + row.addWidget(btn_help) + form.addRow(f"{label}:", row) return w def _add_int(self, form: QFormLayout, key: str, label: str, min_: int, max_: int) -> QSpinBox: @@ -2481,6 +2513,13 @@ SETUP_PROFILES: dict[str, dict[str, Any]] = { ("manual_shift_x", "Manual shift x (µm)", -10.0, 10.0, 3), ("manual_shift_y", "Manual shift y (µm)", -50.0, 50.0, 3), ], + "manual_shift_help": { + "manual_shift_x": ( + "A constant offset applied on top of the alignment, independent of " + "the rotation angle. Normally zero -- only needed in special cases, " + "e.g. when the FZP-to-sample distance is changed after alignment." + ) + }, "piezo_range_fields": [], "offset_fields": [], "offset_getter": None,