Description
Bug summary
( This bug was originally issued in ipympl: matplotlib/ipympl#471 )
I want to use a selector matplotlib.widgets.RectangleSelector , it is incompatible with zoom and pan
So I try to call widgetlock to prevent user from using zoom when the selector is active, hoping that the zoom or pan tools will not be blocked.
This does not work, but crashes rather.
Code for reproduction
import matplotlib.pyplot as plt
fig,ax = plt.subplots()
ax.plot([0,1],[0,1])
fig.canvas.widgetlock(ax) # get the widget lock
plt.show()
Actual outcome
if you then hit the zoom or pan matplotlib button, which also try to get the lock, you get
Traceback (most recent call last):
File "/home/mad/anaconda3/lib/python3.8/site-packages/matplotlib/backends/backend_qt5.py", line 762, in zoom
super().zoom(*args)
File "/home/mad/anaconda3/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 3110, in zoom
self.canvas.widgetlock(self)
File "/home/mad/anaconda3/lib/python3.8/site-packages/matplotlib/widgets.py", line 41, in __call__
raise ValueError('already locked')
ValueError: already locked
Aborted (core dumped)
Expected outcome
The lock is grabbed by the Selector, when zoom it tries to grab the lock, an exception is raised which is the normal behaviour of the lock, however the zoom tool should handle the exception and give-up.
Additional information
100% reproducible in my set-up
Operating system
Ubuntu 20.04
Matplotlib Version
3.3.2
Matplotlib Backend
Qt5Agg
Python version
3.8.5
Jupyter version
N/A
Installation
conda