Skip to content

Commit

Permalink
big move
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Jul 12, 2024
1 parent 4106ea0 commit e4b6f9c
Show file tree
Hide file tree
Showing 57 changed files with 130 additions and 129 deletions.
5 changes: 3 additions & 2 deletions examples/presets_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
mmc.loadSystemConfiguration()

wdg = QWidget()
wdg.setLayout(QFormLayout())
layout = QFormLayout(wdg)
layout.setSpacing(4)

for group in mmc.getAvailableConfigGroups():
gp_wdg = PresetsWidget(group)
wdg.layout().addRow(f"{group}:", gp_wdg)
layout.addRow(f"{group}:", gp_wdg)

wdg.show()

Expand Down
40 changes: 22 additions & 18 deletions src/pymmcore_widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,28 @@
except PackageNotFoundError:
__version__ = "uninstalled"

from ._camera_roi_widget import CameraRoiWidget
from ._channel_group_widget import ChannelGroupWidget
from ._channel_widget import ChannelWidget
from ._device_widget import DeviceWidget, StateDeviceWidget
from ._exposure_widget import DefaultCameraExposureWidget, ExposureWidget
from ._group_preset_widget._group_preset_table_widget import GroupPresetTableWidget
from ._image_widget import ImagePreview
from ._deprecated._device_widget import DeviceWidget, StateDeviceWidget
from ._install_widget import InstallWidget
from ._live_button_widget import LiveButton
from ._load_system_cfg_widget import ConfigurationWidget
from ._objective_widget import ObjectivesWidget
from ._objectives_pixel_configuration_widget import ObjectivesPixelConfigurationWidget
from ._pixel_configuration_widget import PixelConfigurationWidget
from ._presets_widget import PresetsWidget
from ._properties_widget import PropertiesWidget
from ._property_browser import PropertyBrowser
from ._shutter_widget import ShuttersWidget
from ._snap_button_widget import SnapButton
from ._stage_widget import StageWidget
from .config_presets._group_preset_widget._group_preset_table_widget import (
GroupPresetTableWidget,
)
from .config_presets._objectives_pixel_configuration_widget import (
ObjectivesPixelConfigurationWidget,
)
from .config_presets._pixel_configuration_widget import PixelConfigurationWidget
from .control._camera_roi_widget import CameraRoiWidget
from .control._channel_group_widget import ChannelGroupWidget
from .control._channel_widget import ChannelWidget
from .control._exposure_widget import DefaultCameraExposureWidget, ExposureWidget
from .control._live_button_widget import LiveButton
from .control._load_system_cfg_widget import ConfigurationWidget
from .control._objective_widget import ObjectivesWidget
from .control._presets_widget import PresetsWidget
from .control._shutter_widget import ShuttersWidget
from .control._snap_button_widget import SnapButton
from .control._stage_widget import StageWidget
from .device_properties._properties_widget import PropertiesWidget
from .device_properties._property_browser import PropertyBrowser
from .device_properties._property_widget import PropertyWidget
from .hcwizard import ConfigWizard
from .mda import MDAWidget
Expand All @@ -38,6 +41,7 @@
TimePlanWidget,
ZPlanWidget,
)
from .views._image_widget import ImagePreview


def __getattr__(name: str) -> object:
Expand Down
19 changes: 0 additions & 19 deletions src/pymmcore_widgets/_core.py

This file was deleted.

File renamed without changes.
22 changes: 22 additions & 0 deletions src/pymmcore_widgets/_icons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from fonticon_mdi6 import MDI6
from pymmcore_plus import DeviceType

ICONS: dict[DeviceType, str] = {
DeviceType.Any: MDI6.devices,
DeviceType.AutoFocus: MDI6.auto_upload,
DeviceType.Camera: MDI6.camera,
DeviceType.Core: MDI6.checkbox_blank_circle_outline,
DeviceType.Galvo: MDI6.mirror_variant,
DeviceType.Generic: MDI6.dev_to,
DeviceType.Hub: MDI6.hubspot,
DeviceType.ImageProcessor: MDI6.image_auto_adjust,
DeviceType.Magnifier: MDI6.magnify_plus,
DeviceType.Shutter: MDI6.camera_iris,
DeviceType.SignalIO: MDI6.signal,
DeviceType.SLM: MDI6.view_comfy,
DeviceType.Stage: MDI6.arrow_up_down,
DeviceType.State: MDI6.state_machine,
DeviceType.Unknown: MDI6.dev_to,
DeviceType.XYStage: MDI6.arrow_all,
DeviceType.Serial: MDI6.serial_port,
}
3 changes: 0 additions & 3 deletions src/pymmcore_widgets/_install_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@

LOC_ROLE = Qt.ItemDataRole.UserRole + 1

# src/pymmcore_widgets/_install_widget.py
# 83-98, 101-105, 144-148, 152-170, 180-182, 186-199, 203-204, 209-214


class InstallWidget(QWidget):
"""Widget to manage installation of MicroManager.
Expand Down
14 changes: 14 additions & 0 deletions src/pymmcore_widgets/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,17 @@ def resizeEvent(self, event: QResizeEvent | None) -> None:
margins = QMarginsF(xmargin, ymargin, xmargin, ymargin)
self.fitInView(rect.marginsAdded(margins), Qt.AspectRatioMode.KeepAspectRatio)
super().resizeEvent(event)


def load_system_config(config: str = "", mmcore: CMMCorePlus | None = None) -> None:
"""Internal convenience for `loadSystemConfiguration(config)`.
This also unloads all devices first and resets the STATE.
If config is `None` or empty string, will load the MMConfig_demo.
Note that it should also always be fine for the end-user to use something like
`CMMCorePlus.instance().loadSystemConfiguration(...)` (instead of this function)
and we need to handle that as well. So this function shouldn't get too complex.
"""
mmc = mmcore or CMMCorePlus.instance()
mmc.unloadAllDevices()
mmc.loadSystemConfiguration(config or "MMConfig_demo.cfg")
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from ._add_first_preset_widget import AddFirstPresetWidget
from ._add_group_widget import AddGroupWidget
from ._add_preset_widget import AddPresetWidget
from ._edit_group_widget import EditGroupWidget
from ._edit_preset_widget import EditPresetWidget
from ._group_preset_table_widget import GroupPresetTableWidget

__all__ = [
"AddGroupWidget",
"AddFirstPresetWidget",
"AddPresetWidget",
"EditGroupWidget",
"EditPresetWidget",
"GroupPresetTableWidget",
]
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
QWidget,
)

from pymmcore_widgets._device_property_table import DevicePropertyTable
from pymmcore_widgets._device_type_filter import DeviceTypeFilters
from pymmcore_widgets.device_properties._device_property_table import (
DevicePropertyTable,
)
from pymmcore_widgets.device_properties._device_type_filter import DeviceTypeFilters

from ._add_first_preset_widget import AddFirstPresetWidget

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
QWidget,
)

from pymmcore_widgets._device_property_table import DevicePropertyTable
from pymmcore_widgets._device_type_filter import DeviceTypeFilters
from pymmcore_widgets._util import block_core
from pymmcore_widgets.device_properties._device_property_table import (
DevicePropertyTable,
)
from pymmcore_widgets.device_properties._device_type_filter import DeviceTypeFilters


class EditGroupWidget(QDialog):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
QWidget,
)

from pymmcore_widgets._core import load_system_config
from pymmcore_widgets._presets_widget import PresetsWidget
from pymmcore_widgets._util import block_core
from pymmcore_widgets._util import block_core, load_system_config
from pymmcore_widgets.control._presets_widget import PresetsWidget
from pymmcore_widgets.device_properties._property_widget import PropertyWidget

from ._add_group_widget import AddGroupWidget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)
from superqt.utils import signals_blocked

from ._util import block_core, guess_objective_or_prompt
from pymmcore_widgets._util import block_core, guess_objective_or_prompt

OBJECTIVE_LABEL = 0
RESOLUTION_ID = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
)
from superqt.utils import signals_blocked

from pymmcore_widgets._device_property_table import DevicePropertyTable
from pymmcore_widgets._device_type_filter import DeviceTypeFilters
from pymmcore_widgets.device_properties._device_property_table import (
DevicePropertyTable,
)
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
Expand Down
1 change: 1 addition & 0 deletions src/pymmcore_widgets/control/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Widgets that control various devices at runtime."""
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from pymmcore_plus import CMMCorePlus
from qtpy.QtWidgets import QComboBox, QVBoxLayout, QWidget

from ._presets_widget import PresetsWidget
from ._util import ComboMessageBox
from pymmcore_widgets._util import ComboMessageBox
from pymmcore_widgets.control._presets_widget import PresetsWidget


class ChannelWidget(QWidget):
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
from __future__ import annotations

from pymmcore_plus import CMMCorePlus
from qtpy.QtWidgets import (
QFileDialog,
QHBoxLayout,
QLineEdit,
QPushButton,
QWidget,
)
from qtpy.QtWidgets import QFileDialog, QHBoxLayout, QLineEdit, QPushButton, QWidget

from ._core import load_system_config
from pymmcore_widgets._util import load_system_config


class ConfigurationWidget(QWidget):
Expand Down Expand Up @@ -62,21 +56,3 @@ def _browse_cfg(self) -> None:
def _load_cfg(self) -> None:
"""Load the config path currently in the line_edit."""
load_system_config(self.cfg_LineEdit.text(), self._mmc)

def setTitle(self, title: str) -> None:
_show_deprecation("setTitle")

def title(self) -> str:
_show_deprecation("title")
return ""


def _show_deprecation(name: str) -> None:
import warnings

warnings.warn(
"ConfigurationWidget is no longer a QGroupBox. "
f"Please place it in a groupbox if you need {name}",
DeprecationWarning,
stacklevel=3,
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from pymmcore_plus import CMMCorePlus
from qtpy.QtWidgets import QComboBox, QHBoxLayout, QLabel, QSizePolicy, QWidget

from ._device_widget import StateDeviceWidget
from ._util import guess_objective_or_prompt
from pymmcore_widgets._deprecated._device_widget import StateDeviceWidget
from pymmcore_widgets._util import guess_objective_or_prompt


class ObjectivesWidget(QWidget):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
from qtpy.QtWidgets import QComboBox, QHBoxLayout, QWidget
from superqt.utils import signals_blocked

from ._util import block_core
from pymmcore_widgets._util import block_core


class PresetsWidget(QWidget):
"""A Widget to create a QCombobox containing the presets of the specified group.
"""Combobox widget to select the current preset for a given config group.
Parameters
----------
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,20 @@
from logging import getLogger
from typing import Iterable, cast

from fonticon_mdi6 import MDI6
from pymmcore_plus import CMMCorePlus, DeviceProperty, DeviceType
from qtpy.QtCore import Qt
from qtpy.QtGui import QColor
from qtpy.QtWidgets import QAbstractScrollArea, QTableWidget, QTableWidgetItem, QWidget
from superqt.fonticon import icon

from pymmcore_widgets.device_properties._property_widget import PropertyWidget

ICONS: dict[DeviceType, str] = {
DeviceType.Any: MDI6.devices,
DeviceType.AutoFocus: MDI6.auto_upload,
DeviceType.Camera: MDI6.camera,
DeviceType.Core: MDI6.checkbox_blank_circle_outline,
DeviceType.Galvo: MDI6.mirror_variant,
DeviceType.Generic: MDI6.dev_to,
DeviceType.Hub: MDI6.hubspot,
DeviceType.ImageProcessor: MDI6.image_auto_adjust,
DeviceType.Magnifier: MDI6.magnify_plus,
DeviceType.Shutter: MDI6.camera_iris,
DeviceType.SignalIO: MDI6.signal,
DeviceType.SLM: MDI6.view_comfy,
DeviceType.Stage: MDI6.arrow_up_down,
DeviceType.State: MDI6.state_machine,
DeviceType.Unknown: MDI6.dev_to,
DeviceType.XYStage: MDI6.arrow_all,
DeviceType.Serial: MDI6.serial_port,
}
from pymmcore_widgets._icons import ICONS

from ._property_widget import PropertyWidget

logger = getLogger(__name__)

__all__ = ["DevicePropertyTable"]


class DevicePropertyTable(QTableWidget):
"""Table of all currently loaded device properties.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pymmcore_plus import CMMCorePlus
from qtpy.QtWidgets import QGridLayout, QLabel, QWidget

from .device_properties._property_widget import PropertyWidget
from ._property_widget import PropertyWidget

if TYPE_CHECKING:
import re
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from pymmcore_plus import CMMCorePlus
from qtpy.QtWidgets import QDialog, QHBoxLayout, QLineEdit, QVBoxLayout, QWidget

from pymmcore_widgets.device_properties._device_type_filter import DeviceTypeFilters

from ._device_property_table import DevicePropertyTable
from ._device_type_filter import DeviceTypeFilters


class PropertyBrowser(QDialog):
Expand Down
2 changes: 1 addition & 1 deletion src/pymmcore_widgets/experimental.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from ._stack_viewer import StackViewer
from .views._stack_viewer import StackViewer

__all__ = ["StackViewer"]
2 changes: 1 addition & 1 deletion src/pymmcore_widgets/hcwizard/devices_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from superqt.fonticon import icon, setTextIcon
from superqt.utils import exceptions_as_dialog, signals_blocked

from pymmcore_widgets._device_property_table import ICONS
from pymmcore_widgets._icons import ICONS

from ._base_page import ConfigWizardPage
from ._dev_setup_dialog import DeviceSetupDialog
Expand Down
1 change: 1 addition & 0 deletions src/pymmcore_widgets/views/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Widgets that view images and other states."""
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_camera_roi_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from pymmcore_plus import CMMCorePlus

from pymmcore_widgets._camera_roi_widget import CameraRoiWidget
from pymmcore_widgets.control._camera_roi_widget import CameraRoiWidget

if TYPE_CHECKING:
from pytestqt.qtbot import QtBot
Expand Down
4 changes: 2 additions & 2 deletions tests/test_channel_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from qtpy.QtWidgets import QComboBox

from pymmcore_widgets._channel_widget import ChannelWidget
from pymmcore_widgets._presets_widget import PresetsWidget
from pymmcore_widgets._util import block_core
from pymmcore_widgets.control._channel_widget import ChannelWidget
from pymmcore_widgets.control._presets_widget import PresetsWidget

if TYPE_CHECKING:
from pymmcore_plus import CMMCorePlus
Expand Down
Loading

0 comments on commit e4b6f9c

Please sign in to comment.