matplotlib / matplotlib/ipympl

Exception not handled in widgetlock()

Đang mở
#471 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Jupyter Notebook
Star
1.7k
Fork
234
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

## 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:
```python
%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
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Tái hiện vấn đề bằng ví dụ Jupyter tối thiểu, sau đó kiểm tra ipympl/backend_nbagg.py và matplotlib/widgets.py xung quanh phần xử lý khóa widget được thể hiện trong traceback. Xác nhận hành vi mong đợi khi thao tác zoom hoặc pan cố gắng giành được một khóa đang bị chiếm dụng, và bổ sung độ bao phủ cho thấy thao tác tương tác không còn tạo ra ValueError chưa được bắt nữa.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
jupyter-notebook, python
Lĩnh vực
frontend
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.