diff --git a/src/openflexure_microscope_server/things/camera/picamera.py b/src/openflexure_microscope_server/things/camera/picamera.py index 6d38772e..17bfec18 100644 --- a/src/openflexure_microscope_server/things/camera/picamera.py +++ b/src/openflexure_microscope_server/things/camera/picamera.py @@ -770,7 +770,8 @@ class StreamingPiCamera2(BaseCamera): """The calibration actions for both calibration wizard and settings panel.""" return [ action_button_for( - self.full_auto_calibrate, + self, + "full_auto_calibrate", submit_label="Full Auto-Calibrate", can_terminate=False, requires_confirmation=True, @@ -788,13 +789,15 @@ class StreamingPiCamera2(BaseCamera): """The calibration actions that appear only in settings panel.""" return [ action_button_for( - self.auto_expose_from_minimum, + self, + "auto_expose_from_minimum", submit_label="Auto Gain & Shutter Speed", can_terminate=False, button_primary=False, ), action_button_for( - self.calibrate_lens_shading, + self, + "calibrate_lens_shading", submit_label="Auto Flat Field Correction", can_terminate=False, button_primary=False, @@ -806,19 +809,22 @@ class StreamingPiCamera2(BaseCamera): ), ), action_button_for( - self.flat_lens_shading, + self, + "flat_lens_shading", submit_label="Disable Flat Field Correction", can_terminate=False, button_primary=False, ), action_button_for( - self.flat_lens_shading_chrominance, + self, + "flat_lens_shading_chrominance", submit_label="Disable Flat Field Chrominance", can_terminate=False, button_primary=False, ), action_button_for( - self.reset_lens_shading, + self, + "reset_lens_shading", submit_label="Reset Flat Field Correction", can_terminate=False, button_primary=False, diff --git a/src/openflexure_microscope_server/things/camera/simulation.py b/src/openflexure_microscope_server/things/camera/simulation.py index b019a6d8..e1630597 100644 --- a/src/openflexure_microscope_server/things/camera/simulation.py +++ b/src/openflexure_microscope_server/things/camera/simulation.py @@ -385,7 +385,7 @@ class SimulatedCamera(BaseCamera): """The calibration actions for both calibration wizard and settings panel.""" return [ action_button_for( - self.full_auto_calibrate, submit_label="Full Auto-Calibrate" + self, "full_auto_calibrate", submit_label="Full Auto-Calibrate" ), ] @@ -393,8 +393,8 @@ class SimulatedCamera(BaseCamera): def secondary_calibration_actions(self) -> list[ActionButton]: """The calibration actions that appear only in settings panel.""" return [ - action_button_for(self.load_sample, submit_label="Load Sample"), - action_button_for(self.remove_sample, submit_label="Remove Sample"), + action_button_for(self, "load_sample", submit_label="Load Sample"), + action_button_for(self, "remove_sample", submit_label="Remove Sample"), ] @lt.property diff --git a/src/openflexure_microscope_server/ui.py b/src/openflexure_microscope_server/ui.py index 3b7ace59..58641a4f 100644 --- a/src/openflexure_microscope_server/ui.py +++ b/src/openflexure_microscope_server/ui.py @@ -1,6 +1,6 @@ """Functionality for communicating the required user interface for a thing.""" -from typing import Any, Callable +from typing import Any from pydantic import BaseModel @@ -47,14 +47,12 @@ class ActionButton(BaseModel): """The message to show on successful completion.""" -def action_button_for(action: Callable[..., Any], **kwargs: Any) -> ActionButton: +def action_button_for(thing: lt.Thing, action_name: str, **kwargs: Any) -> ActionButton: """Create a ActionButton data for the specified Thing Action. :param action: The thing action to create a button for. :param kwargs: Any attribute of `ActionButton` except for ``thing`` or ``action``. """ - thing = action.args[0] - action_name = action.func.__name__ return ActionButton(thing=thing.name, action=action_name, **kwargs)