René's URL Explorer Experiment


Title: [Bug]: AttributeError: 'QResizeEvent' object has no attribute 'pos' · Issue #22409 · matplotlib/matplotlib · GitHub

Open Graph Title: [Bug]: AttributeError: 'QResizeEvent' object has no attribute 'pos' · Issue #22409 · matplotlib/matplotlib

X Title: [Bug]: AttributeError: 'QResizeEvent' object has no attribute 'pos' · Issue #22409 · matplotlib/matplotlib

Description: Bug summary This bug is similar to #11607. In my case, I get it when I combine PyQt5 and matplotlib 3.5.1. In any of the other combinations (PyQt5 and matplotlib==3.4.3 or PyQt6 and matplotlib==3.5.1) it works as expected. Code for repro...

Open Graph Description: Bug summary This bug is similar to #11607. In my case, I get it when I combine PyQt5 and matplotlib 3.5.1. In any of the other combinations (PyQt5 and matplotlib==3.4.3 or PyQt6 and matplotlib==3.5...

X Description: Bug summary This bug is similar to #11607. In my case, I get it when I combine PyQt5 and matplotlib 3.5.1. In any of the other combinations (PyQt5 and matplotlib==3.4.3 or PyQt6 and matplotlib==3.5...

Opengraph URL: https://github.com/matplotlib/matplotlib/issues/22409

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: AttributeError: 'QResizeEvent' object has no attribute 'pos' ","articleBody":"### Bug summary\n\nThis bug is similar to #11607. In my case, I get it when I combine PyQt5 and matplotlib 3.5.1. In any of the other combinations (PyQt5 and matplotlib==3.4.3 or PyQt6 and matplotlib==3.5.1) it works as expected.\r\n\n\n### Code for reproduction\n\n```python\n# change this to use PyQt5 or PyQt6\r\nqt = 'qt5'\r\n\r\nimport sys\r\nimport matplotlib\r\nfrom matplotlib.figure import Figure\r\nif qt == 'qt6':\r\n    from PyQt6.QtWidgets import *\r\n    from PyQt6.QtCore import *\r\n    from PyQt6.QtGui import *\r\n    if matplotlib.__version__ == '3.4.3':\r\n        raise ValueError('For PyQt6 Install matplotlib 3.5.1')\r\n    from matplotlib.backends.backend_qtagg import (FigureCanvas, NavigationToolbar2QT as NavigationToolbar)\r\n\r\n\r\nelse:\r\n    from PyQt5.QtWidgets import *\r\n    from PyQt5.QtCore import *\r\n    from matplotlib.backends.backend_qt5agg import (FigureCanvasQTAgg as FigureCanvas,\r\n                                                    NavigationToolbar2QT as NavigationToolbar)\r\nimport numpy as np\r\n\r\nprint('Matplotlib version:', matplotlib.__version__)\r\n\r\n\r\nclass ChartsBase(QMdiSubWindow):\r\n    def __init__(self):\r\n        super(ChartsBase, self).__init__()\r\n        self.setMinimumSize(400, 400)\r\n\r\n        self.mainwidgetmdi = QMainWindow()  # must be QMainWindow to handle the toolbar\r\n        self.setWidget(self.mainwidgetmdi)\r\n\r\n        fig = Figure()\r\n        self.figure_canvas = FigureCanvas(fig)\r\n        self.fig = self.figure_canvas.figure\r\n        self.mainwidgetmdi.setCentralWidget(self.figure_canvas)\r\n        # similar to figure canvas\r\n        self.mpl_toolbar = NavigationToolbar(self.figure_canvas, self)\r\n        self.mpl_toolbar.setVisible(True)\r\n        if qt == 'qt6':\r\n            area = Qt.ToolBarArea.BottomToolBarArea\r\n        else:\r\n            area = Qt.BottomToolBarArea\r\n        self.mainwidgetmdi.addToolBar(area, self.mpl_toolbar)\r\n\r\n        t = np.linspace(0, 10, 501)\r\n\r\n        self.axes = self.fig.subplots(1, 1)\r\n        line_plot_ax = self.axes.plot(t)\r\n\r\n\r\nclass MDIWindow(QMainWindow):\r\n    count = 0\r\n\r\n    def __init__(self):\r\n        super().__init__()\r\n\r\n        self.mdi = QMdiArea()\r\n        self.setCentralWidget(self.mdi)\r\n        bar = self.menuBar()\r\n\r\n        file = bar.addMenu(\"File\")\r\n        file.addAction(\"New\")\r\n        file.triggered[QAction].connect(self.add_new)\r\n        self.setWindowTitle(\"MDI Application with matplotlib\")\r\n\r\n    def add_new(self, p):\r\n\r\n        if p.text() == \"New\":\r\n            sub = ChartsBase()\r\n            sub.setWindowTitle(\"Matplotlib example\")\r\n            self.mdi.addSubWindow(sub)\r\n            sub.show()\r\n\r\nif __name__ == '__main__':\r\n    app = QApplication(sys.argv)\r\n    mdi = MDIWindow()\r\n    mdi.show()\r\n    sys.exit(app.exec())\n```\n\n\n### Actual outcome\n\nTo reproduce:\r\n1. execute the app\r\n2. Menu \"File\"\r\n3. \"New\"\r\n4. Maximize the subwindow\r\n\r\nWhen the subwindow is maximized I get this error:\r\n```\r\nTraceback (most recent call last):\r\n  File \"/home/mario/programs/miniconda/lib/python3.8/site-packages/matplotlib/backends/backend_qt.py\", line 262, in enterEvent\r\n    x, y = self.mouseEventCoords(self._get_position(event))\r\nAttributeError: 'QResizeEvent' object has no attribute 'pos'\r\n```\n\n### Expected outcome\n\nThe maximized subwindow\n\n### Additional information\n\n\u003e What are the conditions under which this bug happens? input parameters, edge cases, etc?\r\n\r\nUsing `matplotlib==3.5.1` with `PyQt5`. Not happen with other combinations `matplotlib==3.5.1` and `PyQt6` or `matplotlib==3.4.3` and `PyQt5`\r\n\r\n\u003e Do you know why this bug is happening?\r\n\r\nThis bug is related to the QEvents methods. QResizeEvent does have not any method to get the position in PyQt5, unlike PyQt6 which does have it\r\n\r\n\u003e Do you maybe even know a fix?\r\n\r\nAdd a try-except clausule to this method\r\nhttps://github.com/matplotlib/matplotlib/blob/60d0c33e445a33463d301957d5ee4e97c7565a59/lib/matplotlib/backends/backend_qt.py#L264-L266\r\n```python\r\ndef enterEvent(self, event):\r\n    try:\r\n        x, y = self.mouseEventCoords(self._get_position(event))\r\n    except AttributeError:\r\n        # QResizeEvent has no attribute pos\r\n        x = y = None\r\n    FigureCanvasBase.enter_notify_event(self, guiEvent=event, xy=(x, y))\r\n```\r\nAfter this, work as expected!\r\nHappy to open a PR if it is needed!\r\n\n\n### Operating system\n\nLinux Mint 20.2\n\n### Matplotlib Version\n\n3.5.1\n\n### Matplotlib Backend\n\nQtAgg\n\n### Python version\n\nPython 3.8.5\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/Valdes-Tresanco-MS","@type":"Person","name":"Valdes-Tresanco-MS"},"datePublished":"2022-02-05T19:21:39.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/22409/matplotlib/issues/22409"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:37b488a8-8210-ba3b-bc8d-3c9cfc93fc45
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAE6C:BDE76:4F1EC1E:6E9EF10:6A50F803
html-safe-nonce0ab712dba5684082c7e5cc53df027c636ed7e0003af2e546cbfbedeac410467e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTZDOkJERTc2OjRGMUVDMUU6NkU5RUYxMDo2QTUwRjgwMyIsInZpc2l0b3JfaWQiOiIyMzEzODU5ODMzNzQzMzQxNTcxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmaccf1245b3bcd8b04b39f13ec5421eaf51ceb030babf2e20eff26d957df4e0ae08
hovercard-subject-tagissue:1125010830
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/22409/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4dac8ee2e56946319578d4467fa62f43d01fe05fa3a312066009edb60e9c1560/matplotlib/matplotlib/issues/22409
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4dac8ee2e56946319578d4467fa62f43d01fe05fa3a312066009edb60e9c1560/matplotlib/matplotlib/issues/22409
og:image:altBug summary This bug is similar to #11607. In my case, I get it when I combine PyQt5 and matplotlib 3.5.1. In any of the other combinations (PyQt5 and matplotlib==3.4.3 or PyQt6 and matplotlib==3.5...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameValdes-Tresanco-MS
hostnamegithub.com
expected-hostnamegithub.com
None5266e58c17a510c403505cc811606465e90a881d2007ee7df1c4800d5c659838
turbo-cache-controlno-preview
go-importgithub.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git
octolytics-dimension-user_id215947
octolytics-dimension-user_loginmatplotlib
octolytics-dimension-repository_id1385122
octolytics-dimension-repository_nwomatplotlib/matplotlib
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1385122
octolytics-dimension-repository_network_root_nwomatplotlib/matplotlib
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8d836581d020676cc0ef4a83cd2fe17e4af02c3d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/issues/22409#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F22409
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F22409
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=matplotlib%2Fmatplotlib
Reloadhttps://github.com/matplotlib/matplotlib/issues/22409
Reloadhttps://github.com/matplotlib/matplotlib/issues/22409
Reloadhttps://github.com/matplotlib/matplotlib/issues/22409
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/22409
matplotlib https://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/22409
Notifications https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Fork 8.4k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Star 23k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Code https://github.com/matplotlib/matplotlib
Issues 1.1k https://github.com/matplotlib/matplotlib/issues
Pull requests 410 https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality 0 https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
Code https://github.com/matplotlib/matplotlib
Issues https://github.com/matplotlib/matplotlib/issues
Pull requests https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
[Bug]: AttributeError: 'QResizeEvent' object has no attribute 'pos' https://github.com/matplotlib/matplotlib/issues/22409#top
GUI: Qthttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22GUI%3A%20Qt%22
status: needs confirmationhttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22status%3A%20needs%20confirmation%22
v3.6.0https://github.com/matplotlib/matplotlib/milestone/65
https://github.com/Valdes-Tresanco-MS
Valdes-Tresanco-MShttps://github.com/Valdes-Tresanco-MS
on Feb 5, 2022https://github.com/matplotlib/matplotlib/issues/22409#issue-1125010830
#11607https://github.com/matplotlib/matplotlib/issues/11607
matplotlib/lib/matplotlib/backends/backend_qt.pyhttps://github.com/matplotlib/matplotlib/blob/60d0c33e445a33463d301957d5ee4e97c7565a59/lib/matplotlib/backends/backend_qt.py#L264-L266
60d0c33https://github.com/matplotlib/matplotlib/commit/60d0c33e445a33463d301957d5ee4e97c7565a59
GUI: Qthttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22GUI%3A%20Qt%22
status: needs confirmationhttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22status%3A%20needs%20confirmation%22
v3.6.0https://github.com/matplotlib/matplotlib/milestone/65
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.