FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Prevent blitting errors after canvas swap in RadioButtons and CheckButtons by timhoffm · Pull Request #30945 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
25 changes: 17 additions & 8 deletions lib/matplotlib/widgets.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ def __init__(self, ax, labels, actives=None, *, useblit=True,
if actives is None:
actives = [False] * len(labels)

self._useblit = useblit and self.canvas.supports_blit # TODO: make dynamic
self._useblit = useblit

ys = np.linspace(1, 0, len(labels)+2)[1:-1]

Expand Down Expand Up @@ -1136,7 +1136,10 @@ def __init__(self, ax, labels, actives=None, *, useblit=True,
**cbook.normalize_kwargs(check_props, collections.PathCollection),
'marker': 'x',
'transform': ax.transAxes,
'animated': self._useblit,
'animated': self._useblit and self.canvas.supports_blit,
# TODO: This may need an update when switching out the canvas.
# Can set this to `_useblit` only and live with the animated=True
# overhead on unsupported backends.
}
check_props.setdefault('facecolor', check_props.pop('color', 'black'))
self._checks = ax.scatter([0.15] * len(ys), ys, **check_props)
Expand All @@ -1155,7 +1158,8 @@ def _clear(self, event):
"""Internal event handler to clear the buttons."""
if self.ignore(event) or self.canvas.is_saving():
return
self._save_blit_background(self.canvas.copy_from_bbox(self.ax.bbox))
if self._useblit and self.canvas.supports_blit:
self._save_blit_background(self.canvas.copy_from_bbox(self.ax.bbox))
self.ax.draw_artist(self._checks)

@_call_with_reparented_event
Expand Down Expand Up @@ -1260,7 +1264,7 @@ def set_active(self, index, state=None):
self._checks.set_facecolor(facecolors)

if self.drawon:
if self._useblit:
if self._useblit and self.canvas.supports_blit:
background = self._load_blit_background()
if background is not None:
self.canvas.restore_region(background)
Expand Down Expand Up @@ -1701,7 +1705,7 @@ def __init__(self, ax, labels, active=0, activecolor=None, *,

ys = np.linspace(1, 0, len(labels) + 2)[1:-1]

self._useblit = useblit and self.canvas.supports_blit # TODO: make dynamic
self._useblit = useblit

label_props = _expand_text_props(label_props)
self.labels = [
Expand All @@ -1716,7 +1720,11 @@ def __init__(self, ax, labels, active=0, activecolor=None, *,
**radio_props,
'marker': 'o',
'transform': ax.transAxes,
'animated': self._useblit,
'animated': self._useblit and self.canvas.supports_blit,
# TODO: This may need an update when switching out the canvas.
# Can set this to `_useblit` only and live with the animated=True
# overhead on unsupported backends.

}
radio_props.setdefault('edgecolor', radio_props.get('color', 'black'))
radio_props.setdefault('facecolor',
Expand All @@ -1743,7 +1751,8 @@ def _clear(self, event):
"""Internal event handler to clear the buttons."""
if self.ignore(event) or self.canvas.is_saving():
return
self._save_blit_background(self.canvas.copy_from_bbox(self.ax.bbox))
if self._useblit and self.canvas.supports_blit:
self._save_blit_background(self.canvas.copy_from_bbox(self.ax.bbox))
self.ax.draw_artist(self._buttons)

@_call_with_reparented_event
Expand Down Expand Up @@ -1836,7 +1845,7 @@ def set_active(self, index):
self._buttons.set_facecolor(button_facecolors)

if self.drawon:
if self._useblit:
if self._useblit and self.canvas.supports_blit:
background = self._load_blit_background()
if background is not None:
self.canvas.restore_region(background)
Expand Down
Loading

Back | FazBrowse Home | New Git URL