Skip to content

Commit b1f012f

Browse files
committed
use qt built in context manager signal blocker
1 parent 10d7306 commit b1f012f

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

cellpose/gui/gui.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@
3131

3232
Horizontal = QtCore.Qt.Orientation.Horizontal
3333

34-
from contextlib import contextmanager
35-
36-
@contextmanager
37-
def suppress_signals(widget):
38-
widget.blockSignals(True)
39-
try:
40-
yield
41-
finally:
42-
widget.blockSignals(False)
4334

4435
class Slider(QRangeSlider):
4536

@@ -1008,9 +999,9 @@ def reset(self):
1008999
self.ismanual = np.zeros(0, "bool")
10091000

10101001
# -- set menus to default -- #
1011-
with suppress_signals(self.RGBDropDown):
1002+
with QtCore.QSignalBlocker(self.RGBDropDown):
10121003
self.color = 'RGB'
1013-
with suppress_signals(self.ViewDropDown):
1004+
with QtCore.QSignalBlocker(self.ViewDropDown):
10141005
self.view = 'image'
10151006
self.delete_restore()
10161007

@@ -1517,7 +1508,7 @@ def update_plot(self):
15171508
for r in range(3):
15181509
# setValue on the slider triggers update_plot() so it needs to be suppressed
15191510
slider = self.sliders[r]
1520-
with suppress_signals(slider):
1511+
with QtCore.QSignalBlocker(slider):
15211512
slider.setValue([
15221513
self.saturation[r][self.currentZ][0],
15231514
self.saturation[r][self.currentZ][1]

0 commit comments

Comments
 (0)