|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -from pymmcore_plus import DeviceType |
| 3 | +from pymmcore_plus import CMMCorePlus, DeviceType |
| 4 | +from superqt import QIconifyIcon |
4 | 5 |
|
5 | 6 | ICONS: dict[DeviceType, str] = { |
6 | 7 | DeviceType.Any: "mdi:devices", |
7 | | - DeviceType.AutoFocus: "mdi:auto-upload", |
| 8 | + DeviceType.AutoFocus: "mdi:focus-auto", |
8 | 9 | DeviceType.Camera: "mdi:camera", |
9 | | - DeviceType.Core: "mdi:checkbox-blank-circle-outline", |
| 10 | + DeviceType.Core: "mdi:heart-cog-outline", |
10 | 11 | DeviceType.Galvo: "mdi:mirror-variant", |
11 | 12 | DeviceType.Generic: "mdi:dev-to", |
12 | 13 | DeviceType.Hub: "mdi:hubspot", |
13 | 14 | DeviceType.ImageProcessor: "mdi:image-auto-adjust", |
14 | | - DeviceType.Magnifier: "mdi:magnify-plus", |
| 15 | + DeviceType.Magnifier: "mdi:magnify", |
15 | 16 | DeviceType.Shutter: "mdi:camera-iris", |
16 | | - DeviceType.SignalIO: "mdi:signal", |
| 17 | + DeviceType.SignalIO: "fa6-solid:wave-square", |
17 | 18 | DeviceType.SLM: "mdi:view-comfy", |
18 | 19 | DeviceType.Stage: "mdi:arrow-up-down", |
19 | 20 | DeviceType.State: "mdi:state-machine", |
20 | | - DeviceType.Unknown: "mdi:dev-to", |
| 21 | + DeviceType.Unknown: "mdi:question-mark-rhombus", |
21 | 22 | DeviceType.XYStage: "mdi:arrow-all", |
22 | 23 | DeviceType.Serial: "mdi:serial-port", |
23 | 24 | } |
| 25 | + |
| 26 | + |
| 27 | +def get_device_icon( |
| 28 | + device_type_or_name: DeviceType | str, color: str = "gray" |
| 29 | +) -> QIconifyIcon | None: |
| 30 | + if isinstance(device_type_or_name, str): |
| 31 | + try: |
| 32 | + device_type = CMMCorePlus.instance().getDeviceType(device_type_or_name) |
| 33 | + except Exception: |
| 34 | + device_type = DeviceType.Unknown |
| 35 | + else: |
| 36 | + device_type = device_type_or_name |
| 37 | + if icon_string := ICONS.get(device_type): |
| 38 | + return QIconifyIcon(icon_string, color=color) |
| 39 | + return None |
0 commit comments