matplotlib / matplotlib/ipympl
Exception not handled in widgetlock()
未关闭
还没有人认领这个 Issue。
- 主要语言
- Jupyter Notebook
- 星标
- 1.7k
- 派生
- 234
- PR 合并指标
- 30 天内没有已合并 PR
描述
Describe the issue
I want to use a selector matplotlib.widgets.RectangleSelector , it is incompatible with zoom and pan
So I try to call widget lock to prevent user from using zoom in the same time.
minimum code:
%matplotlib ipympl
import matplotlib.pyplot as plt
fig,ax = plt.subplots()
ax.plot([0,1],[0,1])
fig.canvas.widgetlock(ax) # get the widget lock
if you then hit the zoom or pan matplotlib button, which also try to get the lock, you get
ValueError Traceback (most recent call last)
File ~/spike/venvOW/lib/python3.9/site-packages/ipympl/backend_nbagg.py:279, in Canvas._handle_message(self, object, content, buffers)
276 self.manager.handle_json(content)
278 else:
--> 279 self.manager.handle_json(content)
...
File ~/spike/venvOW/lib/python3.9/site-packages/matplotlib/widgets.py:42, in LockDraw.__call__(self, o)
40 """Reserve the lock for *o*."""
41 if not self.available(o):
---> 42 raise ValueError('already locked')
43 self._owner = o
ValueError: already locked
Alternatively, I could use the right click for the selector, but I have not found a way to restrict zoom and pan to left click only.
Versions
3.9.7 (default, Sep 16 2021, 13:09:58)
[GCC 7.5.0]
ipympl version: 0.8.8
Selected Jupyter core packages...
IPython : 8.0.1
ipykernel : 6.9.1
ipywidgets : 7.6.5
jupyter_client : 7.1.2
jupyter_core : 4.9.2
jupyter_server : 1.13.5
jupyterlab : not installed
nbclient : 0.5.11
nbconvert : 6.4.2
nbformat : 5.1.3
notebook : 6.4.8
qtconsole : 5.2.2
traitlets : 5.1.1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用最小 Jupyter 示例复现该问题,然后检查 ipympl/backend_nbagg.py 和 matplotlib/widgets.py 中 traceback 所示的 widget 锁处理部分。确认 zoom 或 pan 尝试获取已被占用的锁时的预期行为,并添加覆盖测试,以显示该交互不再产生未捕获的 ValueError。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- jupyter-notebook, python
- 领域
- frontend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100