Skip to content

Commit 1ba7bdf

Browse files
fdrgsppre-commit-ci[bot]tlambert03
authored
fix: update shutter widget color when closed (#399)
* fix: set default color for closed to gray * test: fix * pre-commit cfg * fix types * update color * fix for 3.9 * style(pre-commit.ci): auto fixes [...] * remove comment * spacing * fix typing MDAWidget --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Talley Lambert <talley.lambert@gmail.com>
1 parent bbe9833 commit 1ba7bdf

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ repos:
2727
- id: mypy
2828
files: "^src/"
2929
additional_dependencies:
30-
- pymmcore-plus >=0.11.0
30+
- pymmcore-plus >=0.13.4
3131
- useq-schema >=0.5.0

src/pymmcore_widgets/control/_shutter_widget.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
from superqt.fonticon import icon
1212
from superqt.utils import signals_blocked
1313

14+
GRAY = (183, 183, 183)
15+
GREEN = (0, 255, 0)
16+
1417
COLOR_TYPE = Union[
1518
QColor,
1619
int,
@@ -59,8 +62,8 @@ def __init__(
5962

6063
self._icon_open: str = MDI6.hexagon_outline
6164
self._icon_closed: str = MDI6.hexagon_slice_6
62-
self._icon_color_open: COLOR_TYPE = (0, 255, 0)
63-
self._icon_color_closed: COLOR_TYPE = "magenta"
65+
self._icon_color_open: COLOR_TYPE = GREEN
66+
self._icon_color_closed: COLOR_TYPE = GRAY
6467
self._icon_size: int = 25
6568
self._button_text_open: str = ""
6669
self._button_text_closed: str = ""
@@ -143,7 +146,7 @@ def icon_color_closed(self) -> COLOR_TYPE:
143146
"""
144147
Set the button icon color for when the shutter is closed.
145148
146-
Default = 'magenta'
149+
Default = (183, 183, 183)
147150
148151
COLOR_TYPE = Union[QColor, int, str, Qt.GlobalColor, tuple[int, int, int, int],
149152
tuple[int, int, int]]
@@ -203,7 +206,7 @@ def button_text_closed(self, text: str) -> None:
203206
def _create_wdg(self) -> None:
204207
main_layout = QHBoxLayout()
205208
main_layout.setContentsMargins(0, 0, 0, 0)
206-
main_layout.setSpacing(3)
209+
main_layout.setSpacing(7)
207210

208211
self.shutter_button = QPushButton(text=self._button_text_closed)
209212
sizepolicy_btn = QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)

tests/test_shutter_widget.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66

7-
from pymmcore_widgets.control._shutter_widget import ShuttersWidget
7+
from pymmcore_widgets.control._shutter_widget import GRAY, GREEN, ShuttersWidget
88

99
if TYPE_CHECKING:
1010
from pymmcore_plus import CMMCorePlus
@@ -201,13 +201,13 @@ def test_shutter_widget_setters(qtbot: QtBot, global_mmcore: CMMCorePlus):
201201
shutter.icon_size = 30
202202
assert shutter.icon_size == 30
203203

204-
assert shutter.icon_color_open == (0, 255, 0)
205-
shutter.icon_color_open = "magenta"
206-
assert shutter.icon_color_open == "magenta"
204+
assert shutter.icon_color_open == GREEN
205+
shutter.icon_color_open = GRAY
206+
assert shutter.icon_color_open == GRAY
207207

208-
assert shutter.icon_color_closed == "magenta"
209-
shutter.icon_color_closed = (0, 255, 0)
210-
assert shutter.icon_color_closed == (0, 255, 0)
208+
assert shutter.icon_color_closed == GRAY
209+
shutter.icon_color_closed = GREEN
210+
assert shutter.icon_color_closed == GREEN
211211

212212
assert shutter.button_text_open == "Shutter opened"
213213
shutter.button_text_open = "O"

0 commit comments

Comments
 (0)