Unify UI for action_button_for and property_control_for
This commit is contained in:
parent
afbc00acef
commit
51512f36f7
3 changed files with 17 additions and 13 deletions
|
|
@ -770,7 +770,8 @@ class StreamingPiCamera2(BaseCamera):
|
||||||
"""The calibration actions for both calibration wizard and settings panel."""
|
"""The calibration actions for both calibration wizard and settings panel."""
|
||||||
return [
|
return [
|
||||||
action_button_for(
|
action_button_for(
|
||||||
self.full_auto_calibrate,
|
self,
|
||||||
|
"full_auto_calibrate",
|
||||||
submit_label="Full Auto-Calibrate",
|
submit_label="Full Auto-Calibrate",
|
||||||
can_terminate=False,
|
can_terminate=False,
|
||||||
requires_confirmation=True,
|
requires_confirmation=True,
|
||||||
|
|
@ -788,13 +789,15 @@ class StreamingPiCamera2(BaseCamera):
|
||||||
"""The calibration actions that appear only in settings panel."""
|
"""The calibration actions that appear only in settings panel."""
|
||||||
return [
|
return [
|
||||||
action_button_for(
|
action_button_for(
|
||||||
self.auto_expose_from_minimum,
|
self,
|
||||||
|
"auto_expose_from_minimum",
|
||||||
submit_label="Auto Gain & Shutter Speed",
|
submit_label="Auto Gain & Shutter Speed",
|
||||||
can_terminate=False,
|
can_terminate=False,
|
||||||
button_primary=False,
|
button_primary=False,
|
||||||
),
|
),
|
||||||
action_button_for(
|
action_button_for(
|
||||||
self.calibrate_lens_shading,
|
self,
|
||||||
|
"calibrate_lens_shading",
|
||||||
submit_label="Auto Flat Field Correction",
|
submit_label="Auto Flat Field Correction",
|
||||||
can_terminate=False,
|
can_terminate=False,
|
||||||
button_primary=False,
|
button_primary=False,
|
||||||
|
|
@ -806,19 +809,22 @@ class StreamingPiCamera2(BaseCamera):
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
action_button_for(
|
action_button_for(
|
||||||
self.flat_lens_shading,
|
self,
|
||||||
|
"flat_lens_shading",
|
||||||
submit_label="Disable Flat Field Correction",
|
submit_label="Disable Flat Field Correction",
|
||||||
can_terminate=False,
|
can_terminate=False,
|
||||||
button_primary=False,
|
button_primary=False,
|
||||||
),
|
),
|
||||||
action_button_for(
|
action_button_for(
|
||||||
self.flat_lens_shading_chrominance,
|
self,
|
||||||
|
"flat_lens_shading_chrominance",
|
||||||
submit_label="Disable Flat Field Chrominance",
|
submit_label="Disable Flat Field Chrominance",
|
||||||
can_terminate=False,
|
can_terminate=False,
|
||||||
button_primary=False,
|
button_primary=False,
|
||||||
),
|
),
|
||||||
action_button_for(
|
action_button_for(
|
||||||
self.reset_lens_shading,
|
self,
|
||||||
|
"reset_lens_shading",
|
||||||
submit_label="Reset Flat Field Correction",
|
submit_label="Reset Flat Field Correction",
|
||||||
can_terminate=False,
|
can_terminate=False,
|
||||||
button_primary=False,
|
button_primary=False,
|
||||||
|
|
|
||||||
|
|
@ -385,7 +385,7 @@ class SimulatedCamera(BaseCamera):
|
||||||
"""The calibration actions for both calibration wizard and settings panel."""
|
"""The calibration actions for both calibration wizard and settings panel."""
|
||||||
return [
|
return [
|
||||||
action_button_for(
|
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]:
|
def secondary_calibration_actions(self) -> list[ActionButton]:
|
||||||
"""The calibration actions that appear only in settings panel."""
|
"""The calibration actions that appear only in settings panel."""
|
||||||
return [
|
return [
|
||||||
action_button_for(self.load_sample, submit_label="Load Sample"),
|
action_button_for(self, "load_sample", submit_label="Load Sample"),
|
||||||
action_button_for(self.remove_sample, submit_label="Remove Sample"),
|
action_button_for(self, "remove_sample", submit_label="Remove Sample"),
|
||||||
]
|
]
|
||||||
|
|
||||||
@lt.property
|
@lt.property
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"""Functionality for communicating the required user interface for a thing."""
|
"""Functionality for communicating the required user interface for a thing."""
|
||||||
|
|
||||||
from typing import Any, Callable
|
from typing import Any
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
@ -47,14 +47,12 @@ class ActionButton(BaseModel):
|
||||||
"""The message to show on successful completion."""
|
"""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.
|
"""Create a ActionButton data for the specified Thing Action.
|
||||||
|
|
||||||
:param action: The thing action to create a button for.
|
:param action: The thing action to create a button for.
|
||||||
:param kwargs: Any attribute of `ActionButton` except for ``thing`` or ``action``.
|
: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)
|
return ActionButton(thing=thing.name, action=action_name, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue