Title: [Bug]: tkinter backend changes DPI awareness context of entire process on Windows · Issue #21875 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: tkinter backend changes DPI awareness context of entire process on Windows · Issue #21875 · matplotlib/matplotlib
X Title: [Bug]: tkinter backend changes DPI awareness context of entire process on Windows · Issue #21875 · matplotlib/matplotlib
Description: Bug summary _BackendTk.new_figure_manager_given_figure calls _c_internal_utils.Win32_SetProcessDpiAwareness_max, which affects the entire process attached to the script, and all windows part of it, rather than just the matplotlib output ...
Open Graph Description: Bug summary _BackendTk.new_figure_manager_given_figure calls _c_internal_utils.Win32_SetProcessDpiAwareness_max, which affects the entire process attached to the script, and all windows part of it,...
X Description: Bug summary _BackendTk.new_figure_manager_given_figure calls _c_internal_utils.Win32_SetProcessDpiAwareness_max, which affects the entire process attached to the script, and all windows part of it,...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/21875
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: tkinter backend changes DPI awareness context of entire process on Windows","articleBody":"### Bug summary\n\n`_BackendTk.new_figure_manager_given_figure` calls `_c_internal_utils.Win32_SetProcessDpiAwareness_max`, which affects the entire process attached to the script, and all windows part of it, rather than just the matplotlib output window.\r\n\r\nIdeally, the DPI awareness context should only be changed for the current thread before a matplotlib window is drawn and returned to the previous value afterwards, or at the very least there should be an option to disable the DPI change.\n\n### Code for reproduction\n\n```python\n# reproduces the bug when run on a high DPI display on Windows\r\n\r\nimport tkinter as tk\r\nfrom tkinter import ttk\r\n\r\nimport matplotlib\r\nmatplotlib.use('TkAgg') # in case other GUI libraries are installed\r\nimport matplotlib.pyplot as plt\r\n\r\nroot = tk.Tk()\r\n\r\nbutton = ttk.Button(root, text=\"Run matplotlib.pyplot.subplots\",\r\n command=plt.subplots)\r\nbutton.pack(padx=30, pady=30)\r\n\r\nroot.wait_window() #root.mainloop seems to prevent DPI updates\n```\n\n\n### Actual outcome\n\nThe scaling of the window changes.\n\n### Expected outcome\n\nThe scaling of the window shouldn't change just because `subplots` was called.\n\n### Additional information\n\nIntroduced in #19167\n\n### Operating system\n\nWindows 10\n\n### Matplotlib Version\n\n3.5.0\n\n### Matplotlib Backend\n\nTkAgg\n\n### Python version\n\n3.9.6\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/daniilS","@type":"Person","name":"daniilS"},"datePublished":"2021-12-06T17:38:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/21875/matplotlib/issues/21875"}
| 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:8b3681f8-2c31-3426-5045-bdfcc38c489e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E0E2:28D644:1A5DD53:230757C:6A52C5FD |
| html-safe-nonce | 1a680819e1540693a73141c373a7ba72a0d202578f5431b9ad59e85f1cfa3303 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMEUyOjI4RDY0NDoxQTVERDUzOjIzMDc1N0M6NkE1MkM1RkQiLCJ2aXNpdG9yX2lkIjoiNzI3NDM5MzY1Mjk4MTU4MTMwOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bf9ddb062591dc1a539f9637dc5ce8c2a4d772e8ebdfc2c14118afd50138b6e3 |
| hovercard-subject-tag | issue:1072421407 |
| 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/21875/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f5b5a24a37236edd2b345e5f04b37dc89fbda837a480fd7bace6fb7fb1003ea8/matplotlib/matplotlib/issues/21875 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f5b5a24a37236edd2b345e5f04b37dc89fbda837a480fd7bace6fb7fb1003ea8/matplotlib/matplotlib/issues/21875 |
| og:image:alt | Bug summary _BackendTk.new_figure_manager_given_figure calls _c_internal_utils.Win32_SetProcessDpiAwareness_max, which affects the entire process attached to the script, and all windows part of it,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | daniilS |
| 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 | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width