matplotlib / matplotlib/matplotlib

Make Widget.useblit robust against underlying canvas changes

Open
#30,503 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: widgets/UI
Dominant language
Python
Stars
23.2k
Forks
8.5k
Avg merge
1d 6h
Merged PRs (30d)
66

Description

As noted in https://github.com/matplotlib/matplotlib/pull/30490#discussion_r2312635485 (and #30485, the original issue, also #25075), Widget.canvas, which is typically initialized as `self.useblit = useblit and canvas.supports_blit`, is fragile against changes in the underlying canvas (the most common case in practice being a temporarily switch from a canvas that supports blitting to one that doesn't, when saving to vector output).
@tacaswell wrote some code to handle that in #25085, but some further fixes were necessary in #30490 which uses a different approach; a unified way of handling the issue would be nice to have.

**Status:**

- [x] Button
- [x] _SelectorWidget
- [x] SpanSelector
- [x] ToolLineHandles
- [x] ToolHandles
- [x] RectangleSelector
- [x] LassoSelector
- [x] PolygonSelector

Not supported yet:

- [ ] CheckButtons
- [ ] RadioButtons
- [ ] Cursor
- [ ] MultiCursor
- [ ] Lasso

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the discussion in PR #30490, along with issues #30485 and #25075, and review the checked and unchecked widget list in this issue. Trace how Widget.canvas and useblit behave when the canvas changes during vector output; done means the remaining CheckButtons, RadioButtons, Cursor, MultiCursor, and Lasso cases are handled consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.