mirror of
https://github.com/pyapp-kit/superqt.git
synced 2026-01-04 11:21:09 +01:00
docs: document signals blocked (#186)
This commit is contained in:
3
docs/utilities/signal_utils.md
Normal file
3
docs/utilities/signal_utils.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Signal Utilities
|
||||||
|
|
||||||
|
::: superqt.utils.signals_blocked
|
||||||
@@ -7,7 +7,24 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def signals_blocked(obj: "QObject") -> Iterator[None]:
|
def signals_blocked(obj: "QObject") -> Iterator[None]:
|
||||||
"""Context manager to temporarily block signals emitted by QObject: `obj`."""
|
"""Context manager to temporarily block signals emitted by QObject: `obj`.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
obj : QObject
|
||||||
|
The QObject whose signals should be blocked.
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
```python
|
||||||
|
from qtpy.QtWidgets import QSpinBox
|
||||||
|
from superqt import signals_blocked
|
||||||
|
|
||||||
|
spinbox = QSpinBox()
|
||||||
|
with signals_blocked(spinbox):
|
||||||
|
spinbox.setValue(10)
|
||||||
|
```
|
||||||
|
"""
|
||||||
previous = obj.blockSignals(True)
|
previous = obj.blockSignals(True)
|
||||||
try:
|
try:
|
||||||
yield
|
yield
|
||||||
|
|||||||
Reference in New Issue
Block a user