Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move useq_widgets to new top level module #390

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/points_plan_widget.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from qtpy.QtWidgets import QApplication
from useq import RandomPoints

from pymmcore_widgets.useq_widgets import PointsPlanWidget
from useq_widgets import PointsPlanWidget

app = QApplication([])

Expand Down
2 changes: 1 addition & 1 deletion examples/well_plate_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import useq
from qtpy.QtWidgets import QApplication

from pymmcore_widgets.useq_widgets import WellPlateWidget
from useq_widgets import WellPlateWidget

with suppress(ImportError):
from rich import print
Expand Down
17 changes: 9 additions & 8 deletions src/pymmcore_widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
"ZPlanWidget",
]

from useq_widgets import (
ChannelTable,
GridPlanWidget,
MDASequenceWidget,
PositionTable,
TimePlanWidget,
ZPlanWidget,
)

from ._install_widget import InstallWidget
from .config_presets import (
GroupPresetTableWidget,
Expand All @@ -67,14 +76,6 @@
from .hcs import HCSWizard
from .hcwizard import ConfigWizard
from .mda import MDAWidget
from .useq_widgets import (
ChannelTable,
GridPlanWidget,
MDASequenceWidget,
PositionTable,
TimePlanWidget,
ZPlanWidget,
)
from .views import ImagePreview

if TYPE_CHECKING:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
)
from pymmcore_widgets.device_properties._device_type_filter import DeviceTypeFilters
from pymmcore_widgets.device_properties._property_widget import PropertyWidget
from pymmcore_widgets.useq_widgets import DataTable, DataTableWidget
from pymmcore_widgets.useq_widgets._column_info import FloatColumn, TextColumn
from useq_widgets import DataTable, DataTableWidget, FloatColumn, TextColumn

if TYPE_CHECKING:
from collections.abc import Sequence
Expand Down
2 changes: 1 addition & 1 deletion src/pymmcore_widgets/hcs/_hcs_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from qtpy.QtWidgets import QFileDialog, QVBoxLayout, QWidget, QWizard, QWizardPage
from useq import WellPlatePlan

from pymmcore_widgets.useq_widgets import PointsPlanWidget, WellPlateWidget
from useq_widgets import PointsPlanWidget, WellPlateWidget

from ._plate_calibration_widget import PlateCalibrationWidget

Expand Down
2 changes: 1 addition & 1 deletion src/pymmcore_widgets/hcs/_plate_calibration_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
GREEN,
WellCalibrationWidget,
)
from pymmcore_widgets.useq_widgets._well_plate_widget import WellPlateView
from useq_widgets import WellPlateView

if TYPE_CHECKING:
from collections.abc import Mapping
Expand Down
2 changes: 1 addition & 1 deletion src/pymmcore_widgets/mda/_core_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pymmcore_plus import CMMCorePlus

from pymmcore_widgets.useq_widgets import ChannelTable
from useq_widgets import ChannelTable

if TYPE_CHECKING:
from qtpy.QtWidgets import QWidget
Expand Down
2 changes: 1 addition & 1 deletion src/pymmcore_widgets/mda/_core_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pymmcore_plus import CMMCorePlus
from qtpy.QtWidgets import QHBoxLayout, QWidget

from pymmcore_widgets.useq_widgets._grid import GridPlanWidget
from useq_widgets import GridPlanWidget

from ._xy_bounds import CoreXYBoundsControl

Expand Down
19 changes: 10 additions & 9 deletions src/pymmcore_widgets/mda/_core_mda.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@
from useq import MDASequence, Position

from pymmcore_widgets._util import get_next_available_path
from pymmcore_widgets.useq_widgets import MDASequenceWidget
from pymmcore_widgets.useq_widgets._mda_sequence import (
AF_AXIS_TOOLTIP,
AF_DISABLED_TOOLTIP,
from useq_widgets import (
PYMMCW_METADATA_KEY,
MDASequenceWidget,
MDATabs,
TimePlanWidget,
ZMode,
)
from pymmcore_widgets.useq_widgets._positions import AF_PER_POS_TOOLTIP
from pymmcore_widgets.useq_widgets._time import TimePlanWidget
from pymmcore_widgets.useq_widgets._z import Mode

# FIXME: private imports
from useq_widgets._mda_sequence import AF_AXIS_TOOLTIP, AF_DISABLED_TOOLTIP
from useq_widgets._positions import AF_PER_POS_TOOLTIP

from ._core_channels import CoreConnectedChannelTable
from ._core_grid import CoreConnectedGridPlanWidget
Expand Down Expand Up @@ -327,7 +328,7 @@ def _get_tooltip(self, wdg: QWidget) -> str:
# the disabled tooltip
if (
self.tab_wdg.isChecked(self.z_plan)
and self.z_plan.mode() == Mode.TOP_BOTTOM
and self.z_plan.mode() == ZMode.TOP_BOTTOM
and self._mmc.getAutoFocusDevice()
):
return AF_DISABLED_TOOLTIP
Expand All @@ -348,7 +349,7 @@ def _get_autofocus_device(self) -> str | None:
return (
None
if self.tab_wdg.isChecked(self.z_plan)
and self.z_plan.mode() == Mode.TOP_BOTTOM
and self.z_plan.mode() == ZMode.TOP_BOTTOM
else self._mmc.getAutoFocusDevice()
)

Expand Down
14 changes: 9 additions & 5 deletions src/pymmcore_widgets/mda/_core_positions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
from useq import WellPlatePlan

from pymmcore_widgets import HCSWizard
from pymmcore_widgets.useq_widgets import PositionTable
from pymmcore_widgets.useq_widgets._column_info import (
ButtonColumn,
)
from pymmcore_widgets.useq_widgets._positions import AF_PER_POS_TOOLTIP
from useq_widgets import ButtonColumn, PositionTable

if TYPE_CHECKING:
from collections.abc import Sequence
Expand All @@ -33,6 +29,14 @@

UPDATE_POSITIONS = "Update Positions List"
ADD_POSITIONS = "Add to Positions List"
AF_PER_POS_TOOLTIP = (
"If checked, the user can set a different Hardware Autofocus Offset for each "
"Position in the table."
)
AF_DEFAULT_TOOLTIP = (
"If checked, the user can set a different Hardware Autofocus Offset for each "
"Position in the table."
)
AF_UNAVAILABLE = "AutoFocus device unavailable."


Expand Down
13 changes: 9 additions & 4 deletions src/pymmcore_widgets/mda/_core_z.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@
from fonticon_mdi6 import MDI6
from pymmcore_plus import CMMCorePlus

from pymmcore_widgets.useq_widgets._z import ROW_TOP_BOTTOM, Mode, ZPlanWidget
from useq_widgets import ZMode, ZPlanWidget

from ._xy_bounds import MarkVisit

if TYPE_CHECKING:
from qtpy.QtWidgets import QWidget


# avoiding private import from useq_widgets... but could go out of sync
# see if this can be derived better
ROW_TOP_BOTTOM = 4


class CoreConnectedZPlanWidget(ZPlanWidget):
"""[ZPlanWidget](../ZPlanWidget#) connected to a Micro-Manager core instance.

Expand Down Expand Up @@ -51,11 +56,11 @@ def __init__(

def setMode(
self,
mode: Mode | Literal["top_bottom", "range_around", "above_below"],
mode: ZMode | Literal["top_bottom", "range_around", "above_below"],
) -> None:
super().setMode(mode)
self.bottom_btn.setVisible(self._mode == Mode.TOP_BOTTOM)
self.top_btn.setVisible(self._mode == Mode.TOP_BOTTOM)
self.bottom_btn.setVisible(self._mode == ZMode.TOP_BOTTOM)
self.top_btn.setVisible(self._mode == ZMode.TOP_BOTTOM)

def _mark_bottom(self) -> None:
self.bottom.setValue(self._mmc.getZPosition())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,44 @@
from ._channels import ChannelTable
from ._column_info import (
BoolColumn,
ButtonColumn,
ChoiceColumn,
ColumnInfo,
FloatColumn,
IntColumn,
TextColumn,
TimeDeltaColumn,
)
from ._data_table import DataTable, DataTableWidget
from ._grid import GridPlanWidget
from ._mda_sequence import PYMMCW_METADATA_KEY, MDASequenceWidget
from ._mda_sequence import PYMMCW_METADATA_KEY, MDASequenceWidget, MDATabs
from ._positions import PositionTable
from ._time import TimePlanWidget
from ._well_plate_widget import WellPlateWidget
from ._z import ZPlanWidget
from ._well_plate_widget import WellPlateView, WellPlateWidget
from ._z import ZMode, ZPlanWidget
from .points_plans import PointsPlanWidget

__all__ = [
"BoolColumn",
"ButtonColumn",
"ChannelTable",
"ChoiceColumn",
"ColumnInfo",
"DataTable",
"DataTableWidget",
"FloatColumn",
"GridPlanWidget",
"IntColumn",
"MDASequenceWidget",
"MDATabs",
"PointsPlanWidget",
"PositionTable",
"PYMMCW_METADATA_KEY",
"TextColumn",
"TimeDeltaColumn",
"TimePlanWidget",
"WellPlateView",
"WellPlateWidget",
"ZMode",
"ZPlanWidget",
]
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
from superqt.utils import signals_blocked

import pymmcore_widgets
from pymmcore_widgets.useq_widgets._channels import ChannelTable
from pymmcore_widgets.useq_widgets._checkable_tabwidget_widget import CheckableTabWidget
from pymmcore_widgets.useq_widgets._grid import GridPlanWidget
from pymmcore_widgets.useq_widgets._positions import AF_PER_POS_TOOLTIP, PositionTable
from pymmcore_widgets.useq_widgets._time import TimePlanWidget
from pymmcore_widgets.useq_widgets._z import Mode, ZPlanWidget

from ._channels import ChannelTable
from ._checkable_tabwidget_widget import CheckableTabWidget
from ._grid import GridPlanWidget
from ._positions import AF_PER_POS_TOOLTIP, PositionTable
from ._time import TimePlanWidget
from ._z import ZMode, ZPlanWidget

if TYPE_CHECKING:
from collections.abc import Sequence
Expand Down Expand Up @@ -528,7 +529,7 @@ def _validate_af_with_z_plan(self) -> None:

If the Z Plan is set to TOP_BOTTOM, the autofocus plan cannot be used.
"""
if self.z_plan.mode() == Mode.TOP_BOTTOM:
if self.z_plan.mode() == ZMode.TOP_BOTTOM:
# if any autofocus axis is selected, show a warning.
if self.af_axis.value() or self._use_af_per_position():
QMessageBox.warning(
Expand Down
File renamed without changes.
Loading
Loading