Title: [Bug]: rcParam `tk.window_focus: True` is causes crash on Linux in version 3.9.0. · Issue #28374 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: rcParam `tk.window_focus: True` is causes crash on Linux in version 3.9.0. · Issue #28374 · matplotlib/matplotlib
X Title: [Bug]: rcParam `tk.window_focus: True` is causes crash on Linux in version 3.9.0. · Issue #28374 · matplotlib/matplotlib
Description: Bug summary Setting tk.window_focus to True in matplotlibrc or matplotlib.rcParams causes a crash when plotting on a Linux system with matplotlib 3.9.0. Code for reproduction import matplotlib as mpl # I removed my system-wide matplotlib...
Open Graph Description: Bug summary Setting tk.window_focus to True in matplotlibrc or matplotlib.rcParams causes a crash when plotting on a Linux system with matplotlib 3.9.0. Code for reproduction import matplotlib as m...
X Description: Bug summary Setting tk.window_focus to True in matplotlibrc or matplotlib.rcParams causes a crash when plotting on a Linux system with matplotlib 3.9.0. Code for reproduction import matplotlib as m...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/28374
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: rcParam `tk.window_focus: True` is causes crash on Linux in version 3.9.0.","articleBody":"### Bug summary\n\nSetting `tk.window_focus` to `True` in `matplotlibrc` or `matplotlib.rcParams` causes a crash when plotting on a Linux system with matplotlib 3.9.0.\n\n### Code for reproduction\n\n```Python\nimport matplotlib as mpl\r\n\r\n# I removed my system-wide matplotlibrc file for this test, but the same\r\n# behavior is produced when the following are set in matplotlibrc instead.\r\nmpl.use('TkAgg')\r\nmpl.rcParams['tk.window_focus'] = True\r\n\r\nimport matplotlib.pyplot as plt\r\n\r\nplt.plot([1, 2, 3])\r\nplt.show()\n```\n\n\n### Actual outcome\n\nNo plot is produced, and a `TypeError` is thrown with the following traceback:\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"/home/zach/temp/mpl-test/test.py\", line 10, in \u003cmodule\u003e\r\n plt.plot([1, 2, 3])\r\n File \"/home/zach/.local/share/venvs/c1078f6cd069ee2916e64fe0fd9fd7f2/venv/lib/python3.12/site-packages/matplotlib/pyplot.py\", line 3708, in plot\r\n return gca().plot(\r\n ^^^^^\r\n File \"/home/zach/.local/share/venvs/c1078f6cd069ee2916e64fe0fd9fd7f2/venv/lib/python3.12/site-packages/matplotlib/pyplot.py\", line 2656, in gca\r\n return gcf().gca()\r\n ^^^^^\r\n File \"/home/zach/.local/share/venvs/c1078f6cd069ee2916e64fe0fd9fd7f2/venv/lib/python3.12/site-packages/matplotlib/pyplot.py\", line 1088, in gcf\r\n return figure()\r\n ^^^^^^^^\r\n File \"/home/zach/.local/share/venvs/c1078f6cd069ee2916e64fe0fd9fd7f2/venv/lib/python3.12/site-packages/matplotlib/pyplot.py\", line 1022, in figure\r\n manager = new_figure_manager(\r\n ^^^^^^^^^^^^^^^^^^^\r\n File \"/home/zach/.local/share/venvs/c1078f6cd069ee2916e64fe0fd9fd7f2/venv/lib/python3.12/site-packages/matplotlib/pyplot.py\", line 545, in new_figure_manager\r\n return _get_backend_mod().new_figure_manager(*args, **kwargs)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/zach/.local/share/venvs/c1078f6cd069ee2916e64fe0fd9fd7f2/venv/lib/python3.12/site-packages/matplotlib/backend_bases.py\", line 3521, in new_figure_manager\r\n return cls.new_figure_manager_given_figure(num, fig)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/zach/.local/share/venvs/c1078f6cd069ee2916e64fe0fd9fd7f2/venv/lib/python3.12/site-packages/matplotlib/backend_bases.py\", line 3526, in new_figure_manager_given_figure\r\n return cls.FigureCanvas.new_manager(figure, num)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/zach/.local/share/venvs/c1078f6cd069ee2916e64fe0fd9fd7f2/venv/lib/python3.12/site-packages/matplotlib/backend_bases.py\", line 1811, in new_manager\r\n return cls.manager_class.create_with_canvas(cls, figure, num)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/zach/.local/share/venvs/c1078f6cd069ee2916e64fe0fd9fd7f2/venv/lib/python3.12/site-packages/matplotlib/backends/_backend_tk.py\", line 479, in create_with_canvas\r\n with _restore_foreground_window_at_end():\r\n File \"/usr/lib/python3.12/contextlib.py\", line 144, in __exit__\r\n next(self.gen)\r\n File \"/home/zach/.local/share/venvs/c1078f6cd069ee2916e64fe0fd9fd7f2/venv/lib/python3.12/site-packages/matplotlib/backends/_backend_tk.py\", line 48, in _restore_foreground_window_at_end\r\n _c_internal_utils.Win32_SetForegroundWindow(foreground)\r\nTypeError: Win32_SetForegroundWindow(): incompatible function arguments. The following argument types are supported:\r\n 1. (hwnd: capsule) -\u003e None\r\n\r\nInvoked with: None\r\n```\n\n### Expected outcome\n\nThe following figure is produced with the same code using matplotlib 3.8.4:\r\n\r\n\r\n\n\n### Additional information\n\nThe bug occurs in Linux with matplotlib 3.9.0, when `tk.window_focus` is `True` in `matplotlibrc` or `matplotlib.rcParams`. The appropriate plot is produced if either of these conditions is changed, i.e. both of the following produce the correct plot:\r\n- matplotlib 3.8.4 with `tk.window_focus: True`\r\n- matplotlib 3.9.0 with `tk.window_focus: False`\r\n\r\nI think the bug is related to https://github.com/matplotlib/matplotlib/commit/0097b024305c2866464516db839f7c033dcaa73d, though I'm not quite sure how to fix it.\n\n### Operating system\n\nArch Linux\n\n### Matplotlib Version\n\n3.9.0\n\n### Matplotlib Backend\n\ntkagg\n\n### Python version\n\nPython 3.12.3\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/Z2h-A6n","@type":"Person","name":"Z2h-A6n"},"datePublished":"2024-06-11T14:53:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/28374/matplotlib/issues/28374"}
| 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:a9bdaad3-efe1-67d0-cb8f-ee27af99fe14 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9D96:290D1F:12DBF32:198A478:6A5346F7 |
| html-safe-nonce | 5afafeee71d4fa7cc3f90dd382c3323ec56d1981c61b5f85e8260d80ee1167ca |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDk2OjI5MEQxRjoxMkRCRjMyOjE5OEE0Nzg6NkE1MzQ2RjciLCJ2aXNpdG9yX2lkIjoiMTkzNTk3NjQ4NjM0ODczNjI0NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6967a8374257a00fc925efa29e8afe386143cc0f0ffe69032ca44c08336532b0 |
| hovercard-subject-tag | issue:2346643557 |
| 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/28374/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1455c46a9c36ea0116e58c07c31cbe39eea9285a56700b3f3cb4d6234ccc42cb/matplotlib/matplotlib/issues/28374 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1455c46a9c36ea0116e58c07c31cbe39eea9285a56700b3f3cb4d6234ccc42cb/matplotlib/matplotlib/issues/28374 |
| og:image:alt | Bug summary Setting tk.window_focus to True in matplotlibrc or matplotlib.rcParams causes a crash when plotting on a Linux system with matplotlib 3.9.0. Code for reproduction import matplotlib as m... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Z2h-A6n |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width