Title: Fix blitting selector by ericpre · Pull Request #20264 · matplotlib/matplotlib · GitHub
Open Graph Title: Fix blitting selector by ericpre · Pull Request #20264 · matplotlib/matplotlib
X Title: Fix blitting selector by ericpre · Pull Request #20264 · matplotlib/matplotlib
Description: PR Summary This PR fixes two bugs with blitting Selectors: A recursive paint loop when resizing the figure with the qt backend. Fix a similar issue as describe in #9660 but for RectangleSelector/EllipseSelector and SpanSelector once #20113 is merged, therefore fixing #9660 too! To reproduce 1 Fix in 94a2f46 From a juptyer qtconsole: %matplotlib qt import matplotlib.pyplot as plt from matplotlib.widgets import RectangleSelector import numpy as np values = np.arange(100) fig = plt.figure() ax = fig.add_subplot() ax.plot(values) span = RectangleSelector(ax, print, useblit=True, interactive=True) # flush events to get a first draw of the figure before setting the extents fig.canvas.flush_events() span.extents = (26, 55, 32, 71) When resizing the figure, the figure is flickering (in spyder the console crashes when a custom DPI scaling is used) and it gives the following error: QWidget::repaint: Recursive repaint detected QWidget::paintEngine: Should no longer be called QPainter::begin: Paint device returned engine == 0, type: 1 QPainter::end: Painter not active, aborted My understanding is that calling _SelectorWidget.ax.blit in _SelectorWidget.update_background (through _SelectorWidget.update) when resizing the figure create the recursive repaint loop. To reproduce 2 Fix in 031f77c Adapted from #9660 to reproduce the issue with RectangleSelector and this PR uses the fix suggested in #9660 (comment) import sys from PyQt5.QtWidgets import * from matplotlib.backends.backend_qt5agg import * from matplotlib.figure import Figure from matplotlib.widgets import RectangleSelector class App(QMainWindow): def __init__(self): super().__init__() self.setCentralWidget(QWidget()) layout = QVBoxLayout() self.centralWidget().setLayout(layout) self._fig = Figure() self._fig.subplots() layout.addWidget(FigureCanvas(self._fig)) layout.addWidget(QPushButton("span", clicked=self._span_cb)) def _span_cb(self): self._span = RectangleSelector( self._fig.axes[0], print, useblit=True) qapp = QApplication(sys.argv) app = App() app.show() qapp.exec_() The selector is included in the background: PR Checklist Has pytest style unit tests (and pytest passes). Is Flake 8 compliant (run flake8 on changed files to check). New features are documented, with examples if plot related. Documentation is sphinx and numpydoc compliant (the docs should build without error). Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all). New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there). API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
Open Graph Description: PR Summary This PR fixes two bugs with blitting Selectors: A recursive paint loop when resizing the figure with the qt backend. Fix a similar issue as describe in #9660 but for RectangleSelector/E...
X Description: PR Summary This PR fixes two bugs with blitting Selectors: A recursive paint loop when resizing the figure with the qt backend. Fix a similar issue as describe in #9660 but for RectangleSelector/E...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/20264
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:bc595ead-1eb9-886e-a0c3-bbe912abd3d9 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 98CA:339F37:19844FD:2503AEB:6A54DC7B |
| html-safe-nonce | fa3af279b7241086a8a875807653bd595c865adb8ace26d858948b614c673b47 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OENBOjMzOUYzNzoxOTg0NEZEOjI1MDNBRUI6NkE1NERDN0IiLCJ2aXNpdG9yX2lkIjoiMjcyMjIzMTc3MDk5MzE4Nzk2MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c85f69ba1c9f4d6ed914a8c15c49b60da3be46d439b9ab9bdd3ec868d6a6870f |
| hovercard-subject-tag | pull_request:647803014 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/matplotlib/matplotlib/pull/20264/files |
| twitter:image | https://avatars.githubusercontent.com/u/11851990?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/11851990?s=400&v=4 |
| og:image:alt | PR Summary This PR fixes two bugs with blitting Selectors: A recursive paint loop when resizing the figure with the qt backend. Fix a similar issue as describe in #9660 but for RectangleSelector/E... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | a556215b071af6609619e2bbe6f00bdfbf0812ad723b1ae6c301858a7a829f54 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 00f21e38abd06cd6752db5c227083570f72fdb6c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width