Force an update of the background.
(self, event)
| 2369 | if a.get_animated() and a not in self.artists) |
| 2370 | |
| 2371 | def update_background(self, event): |
| 2372 | """Force an update of the background.""" |
| 2373 | # If you add a call to `ignore` here, you'll want to check edge case: |
| 2374 | # `release` can call a draw event even when `ignore` is True. |
| 2375 | if not self.useblit: |
| 2376 | return |
| 2377 | if self.canvas.is_saving(): |
| 2378 | return # saving does not use blitting |
| 2379 | # Make sure that widget artists don't get accidentally included in the |
| 2380 | # background, by re-rendering the background if needed (and then |
| 2381 | # re-re-rendering the canvas with the visible widget artists). |
| 2382 | # We need to remove all artists which will be drawn when updating |
| 2383 | # the selector: if we have animated artists in the figure, it is safer |
| 2384 | # to redrawn by default, in case they have updated by the callback |
| 2385 | # zorder needs to be respected when redrawing |
| 2386 | artists = sorted(self.artists + self._get_animated_artists(), |
| 2387 | key=lambda a: a.get_zorder()) |
| 2388 | needs_redraw = any(artist.get_visible() for artist in artists) |
| 2389 | with ExitStack() as stack: |
| 2390 | if needs_redraw: |
| 2391 | for artist in artists: |
| 2392 | stack.enter_context(artist._cm_set(visible=False)) |
| 2393 | self.canvas.draw() |
| 2394 | self._save_blit_background(self.canvas.copy_from_bbox(self.ax.bbox)) |
| 2395 | if needs_redraw: |
| 2396 | for artist in artists: |
| 2397 | self.ax.draw_artist(artist) |
| 2398 | |
| 2399 | def connect_default_events(self): |
| 2400 | """Connect the major canvas events to methods.""" |
no test coverage detected