Skip to content

Commit

Permalink
typing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Jan 27, 2025
1 parent 930c0a9 commit 4796eb0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/pymmcore_widgets/mda/_xy_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ def value(self) -> dict[str, float]:
"""Return the current value of the grid plan widget."""
return self._bounds_wdg.value()

def setValue(self, value: useq.GridFromEdges) -> None:
def setValue(self, plan: useq.GridFromEdges) -> None:
"""Set the value of the grid plan widget."""
self._bounds_wdg.setValue(value)
self._bounds_wdg.setValue(plan)

def _mark_or_visit(self, top: bool | None = None, left: bool | None = None) -> None:
self._visit(top, left) if self.go_middle.isChecked() else self._mark(top, left)
Expand Down
11 changes: 6 additions & 5 deletions src/pymmcore_widgets/useq_widgets/_grid.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from enum import Enum
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Protocol

import useq
from qtpy.QtCore import Qt, Signal
Expand Down Expand Up @@ -32,6 +32,9 @@
useq.GridFromEdges | useq.GridRowsColumns | useq.GridWidthHeight
)

class ValueWidget(Protocol, QWidget): # pyright: ignore
def setValue(self, plan: Any) -> None: ...


class RelativeTo(Enum):
center = "center"
Expand Down Expand Up @@ -105,9 +108,7 @@ def __init__(self, parent: QWidget | None = None):
self.width_height_wdg = _WidthHeightWidget()
self.bounds_wdg = _BoundsWidget()
# ease of lookup
self._mode_to_widget: dict[
Mode, _RowsColsWidget | _WidthHeightWidget | _BoundsWidget
] = {
self._mode_to_widget: dict[Mode, ValueWidget] = {
Mode.NUMBER: self.row_col_wdg,
Mode.AREA: self.width_height_wdg,
Mode.BOUNDS: self.bounds_wdg,
Expand Down Expand Up @@ -226,7 +227,7 @@ def setValue(self, value: GridPlan) -> None:

with signals_blocked(self):
mode_wdg = self._mode_to_widget[mode]
mode_wdg.setValue(value) # type: ignore [arg-type]
mode_wdg.setValue(value)
self._stack.setCurrentWidget(mode_wdg)
if value.fov_height:
self._fov_height = value.fov_height
Expand Down

0 comments on commit 4796eb0

Please sign in to comment.