Skip to content
Merged
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
28 changes: 22 additions & 6 deletions src/pymmcore_widgets/_icons.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
from __future__ import annotations

from pymmcore_plus import DeviceType
from pymmcore_plus import CMMCorePlus, DeviceType
from superqt import QIconifyIcon

ICONS: dict[DeviceType, str] = {
DeviceType.Any: "mdi:devices",
DeviceType.AutoFocus: "mdi:auto-upload",
DeviceType.AutoFocus: "mdi:focus-auto",
DeviceType.Camera: "mdi:camera",
DeviceType.Core: "mdi:checkbox-blank-circle-outline",
DeviceType.Core: "mdi:heart-cog-outline",
DeviceType.Galvo: "mdi:mirror-variant",
DeviceType.Generic: "mdi:dev-to",
DeviceType.Hub: "mdi:hubspot",
DeviceType.ImageProcessor: "mdi:image-auto-adjust",
DeviceType.Magnifier: "mdi:magnify-plus",
DeviceType.Magnifier: "mdi:magnify",
DeviceType.Shutter: "mdi:camera-iris",
DeviceType.SignalIO: "mdi:signal",
DeviceType.SignalIO: "fa6-solid:wave-square",
DeviceType.SLM: "mdi:view-comfy",
DeviceType.Stage: "mdi:arrow-up-down",
DeviceType.State: "mdi:state-machine",
DeviceType.Unknown: "mdi:dev-to",
DeviceType.Unknown: "mdi:question-mark-rhombus",
DeviceType.XYStage: "mdi:arrow-all",
DeviceType.Serial: "mdi:serial-port",
}


def get_device_icon(
device_type_or_name: DeviceType | str, color: str = "gray"
) -> QIconifyIcon | None:
if isinstance(device_type_or_name, str):
try:
device_type = CMMCorePlus.instance().getDeviceType(device_type_or_name)
except Exception:
device_type = DeviceType.Unknown

Check warning on line 34 in src/pymmcore_widgets/_icons.py

View check run for this annotation

Codecov / codecov/patch

src/pymmcore_widgets/_icons.py#L33-L34

Added lines #L33 - L34 were not covered by tests
else:
device_type = device_type_or_name

Check warning on line 36 in src/pymmcore_widgets/_icons.py

View check run for this annotation

Codecov / codecov/patch

src/pymmcore_widgets/_icons.py#L36

Added line #L36 was not covered by tests
if icon_string := ICONS.get(device_type):
return QIconifyIcon(icon_string, color=color)
return None

Check warning on line 39 in src/pymmcore_widgets/_icons.py

View check run for this annotation

Codecov / codecov/patch

src/pymmcore_widgets/_icons.py#L39

Added line #L39 was not covered by tests
2 changes: 2 additions & 0 deletions src/pymmcore_widgets/config_presets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
from ._group_preset_widget._group_preset_table_widget import GroupPresetTableWidget
from ._objectives_pixel_configuration_widget import ObjectivesPixelConfigurationWidget
from ._pixel_configuration_widget import PixelConfigurationWidget
from ._qmodel._config_model import QConfigGroupsModel

__all__ = [
"GroupPresetTableWidget",
"ObjectivesPixelConfigurationWidget",
"PixelConfigurationWidget",
"QConfigGroupsModel",
]
Empty file.
Loading