diff --git a/lib/matplotlib/widgets.py b/lib/matplotlib/widgets.py index 13f7287fe375..7518c2f4700f 100644 --- a/lib/matplotlib/widgets.py +++ b/lib/matplotlib/widgets.py @@ -62,6 +62,12 @@ def locked(self): """Return whether the lock is currently held by an owner.""" return self._owner is not None + def __enter__(self): + return self + + def __exit__(self, *args): + self.release(self) + class Widget: """