Title: [Bug]: backend bug in matplotlib==3.6.1 with python3.11 and PySide6==6.4.0.1 · Issue #24332 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: backend bug in matplotlib==3.6.1 with python3.11 and PySide6==6.4.0.1 · Issue #24332 · matplotlib/matplotlib
X Title: [Bug]: backend bug in matplotlib==3.6.1 with python3.11 and PySide6==6.4.0.1 · Issue #24332 · matplotlib/matplotlib
Description: Bug summary backend bug in matplotlib==3.6.1 with python3.11 same issue happend when embeding in Qt with PySide6==6.4.0.1 error report int() argument must be a string, a bytes-like object or a real number, not 'KeyboardModifier' This is ...
Open Graph Description: Bug summary backend bug in matplotlib==3.6.1 with python3.11 same issue happend when embeding in Qt with PySide6==6.4.0.1 error report int() argument must be a string, a bytes-like object or a real...
X Description: Bug summary backend bug in matplotlib==3.6.1 with python3.11 same issue happend when embeding in Qt with PySide6==6.4.0.1 error report int() argument must be a string, a bytes-like object or a real...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/24332
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: backend bug in matplotlib==3.6.1 with python3.11 and PySide6==6.4.0.1 ","articleBody":"### Bug summary\n\nbackend bug in matplotlib==3.6.1 with python3.11\r\n\r\nsame issue happend when embeding in Qt with PySide6==6.4.0.1 \r\n\r\nerror report\r\nint() argument must be a string, a bytes-like object or a real number, not 'KeyboardModifier'\r\n\r\nThis is caused by the \"The new Enum system\" within the release of PySide6, Qt for Python 6.4\r\n\r\nSee\r\n[Qt for python release 6.4 ](https://www.qt.io/blog/qt-for-python-release-6.4-is-finally-here)\r\n\r\nPySide is in the interesting position of being both Qt (with its C++ roots and all that entails) but also distinctly Python. Where possible, we strive to align PySide further with Python conventions and use as many Python features as we can, if they make sense. \r\n\r\nQuote below:\r\n\r\nThe new Enum system\r\n\r\nOne such area that we tackled now affects enums, which was implemented as bound C++ classes, but now it is updated to leverage [Python's own enum mechanism](https://docs.python.org/3/library/enum.html). \r\n\r\nAlthough the new Python enums and the old Shiboken-based ones are compatible with each other, but there are a few differences or restrictions: \r\n\r\nPython enums cannot be inherited from each other, whereas Shiboken enums can \r\nPython enums do not allow undefined values, Shiboken enums do \r\nPython enums always need exactly one argument, Shiboken enums have a default zero value \r\nPython enums rarely inherit from int, Shiboken enums always do \r\nYou can see that some of these differences are between flags. For example, until now, you could either write \r\n\r\n flags = Qt.Alignment() \r\n\r\n enum = Qt.AlignmentFlag \r\n\r\nor use the enum shortcuts like these:\r\n\r\n Qt.AlignLeft = Qt.AlignmentFlag.AlignLeft \r\n\r\n Qt.AlignTop = Qt.AlignmentFlag.AlignTop\r\n\r\nThese shortcuts, and flags no longer exist (officially) from 6.4.0 onwards. Instead, Python has an [enum.Flags](https://docs.python.org/3/library/enum.html#enum.Flag) class, which is a subclass of the [enum.Enum](https://docs.python.org/3/library/enum.html#enum.Enum) class. \r\n\r\nIf the thought of updating all your code left and right makes you sweat more than an overheated pumpkin spice latte, do not fret, for salvation has a name, and it’s “forgiveness mode”. This transitory mode allows you to continue using the old constructs but translates them internally into the new ones. For example, if you write \r\n\r\n flags = Qt.Alignment() \r\n\r\n enum = Qt.AlignLeft \r\n\r\n item.setForeground(QColor(Qt.green)) \r\n\r\n flags_type = QPainter.RenderHints \r\n\r\n flags = QPainter.RenderHints() \r\n\r\n chart_view.setRenderHint(QPainter.Antialiasing) \r\n\r\nyou get a construct that mimics the following code, which is the recommended way of using flags and enums: \r\n\r\n flags = Qt.AlignmentFlag(0) \r\n\r\n enum = Qt.AlignmentFlag.AlignLeft \r\n\r\n item.setForeground(QColor(Qt.GlobalColor.green)) \r\n\r\n flags_type = QPainter.RenderHint \r\n\r\n flags = QPainter.RenderHint(0) \r\n\r\n chart_view.setRenderHint(QPainter.RenderHint.Antialiasing) \r\n\r\nWith this you can at least initially ignore the difference between old and new enums, as long as the new enums are properties of classes.\n\n### Code for reproduction\n\n```python\nimport matplotlib\r\nprint(matplotlib.get_backend())\r\n\r\nor \r\n\r\nfrom matplotlib.backends.qt_compat import QtWidgets\r\nfrom matplotlib.backends.backend_qtagg import (\r\n FigureCanvas, NavigationToolbar2QT as NavigationToolbar)\r\nfrom matplotlib.figure import Figure\n```\n\n\n### Actual outcome\n\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\n File \"C:\\Python311\\Lib\\site-packages\\matplotlib\\__init__.py\", line 1182, in get_backend\r\n return rcParams['backend']\r\n ~~~~~~~~^^^^^^^^^^^\r\n File \"C:\\Python311\\Lib\\site-packages\\matplotlib\\__init__.py\", line 677, in __getitem__\r\n plt.switch_backend(rcsetup._auto_backend_sentinel)\r\n File \"C:\\Python311\\Lib\\site-packages\\matplotlib\\pyplot.py\", line 252, in switch_backend\r\n switch_backend(candidate)\r\n File \"C:\\Python311\\Lib\\site-packages\\matplotlib\\pyplot.py\", line 265, in switch_backend\r\n backend_mod = importlib.import_module(\r\n ^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"C:\\Python311\\Lib\\importlib\\__init__.py\", line 126, in import_module\r\n return _bootstrap._gcd_import(name[level:], package, level)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"\u003cfrozen importlib._bootstrap\u003e\", line 1206, in _gcd_import\r\n File \"\u003cfrozen importlib._bootstrap\u003e\", line 1178, in _find_and_load\r\n File \"\u003cfrozen importlib._bootstrap\u003e\", line 1149, in _find_and_load_unlocked\r\n File \"\u003cfrozen importlib._bootstrap\u003e\", line 690, in _load_unlocked\r\n File \"\u003cfrozen importlib._bootstrap_external\u003e\", line 940, in exec_module\r\n File \"\u003cfrozen importlib._bootstrap\u003e\", line 241, in _call_with_frames_removed\r\n File \"C:\\Python311\\Lib\\site-packages\\matplotlib\\backends\\backend_qtagg.py\", line 12, in \u003cmodule\u003e\r\n from .backend_qt import QtCore, QtGui, _BackendQT, FigureCanvasQT\r\n File \"C:\\Python311\\Lib\\site-packages\\matplotlib\\backends\\backend_qt.py\", line 72, in \u003cmodule\u003e\r\n _MODIFIER_KEYS = [\r\n ^\r\n File \"C:\\Python311\\Lib\\site-packages\\matplotlib\\backends\\backend_qt.py\", line 73, in \u003clistcomp\u003e\r\n (_to_int(getattr(_enum(\"QtCore.Qt.KeyboardModifier\"), mod)),\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\nTypeError: int() argument must be a string, a bytes-like object or a real number, not 'KeyboardModifier'\n\n### Expected outcome\n\nQtAgg\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nWindows\n\n### Matplotlib Version\n\n3.6.1\n\n### Matplotlib Backend\n\nerror as reported \n\n### Python version\n\n3.11\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/zlmturnout","@type":"Person","name":"zlmturnout"},"datePublished":"2022-11-01T12:40:08.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/24332/matplotlib/issues/24332"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:51db7cfa-6216-295c-6a89-fa702602cc95 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9D1A:2E1DA7:2CBF72C:3EA863E:6A50DD34 |
| html-safe-nonce | d370c96314b61cedbac13fae59eae22f2bd0111c9986ec66e73b64d3b21cbd0e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDFBOjJFMURBNzoyQ0JGNzJDOjNFQTg2M0U6NkE1MEREMzQiLCJ2aXNpdG9yX2lkIjoiNjIyNzU4NDM5OTUzNjg1ODEyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e3facf40fb367e63f0bda7d7976c326574d3f2477c23f12bc5d1f5fcaf87e73a |
| hovercard-subject-tag | issue:1431362922 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/matplotlib/matplotlib/24332/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a2fbaf6e298d679c6474cf8c8e80007f7e4dbaa243890f8cc50616a0e5d0dbe6/matplotlib/matplotlib/issues/24332 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a2fbaf6e298d679c6474cf8c8e80007f7e4dbaa243890f8cc50616a0e5d0dbe6/matplotlib/matplotlib/issues/24332 |
| og:image:alt | Bug summary backend bug in matplotlib==3.6.1 with python3.11 same issue happend when embeding in Qt with PySide6==6.4.0.1 error report int() argument must be a string, a bytes-like object or a real... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zlmturnout |
| hostname | github.com |
| expected-hostname | github.com |
| None | 72b13e0e8d0319acdd27a145cfe73f4f06c791713d0ac4690e41fb68ad28cac0 |
| turbo-cache-control | no-preview |
| 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 | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 17290b65caabb92b271e0949d1bf147b63deab41 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width