Title: [Bug]: TclError raised by _set_image_for_button() when _update_window_dpi() runs · Issue #22836 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: TclError raised by _set_image_for_button() when _update_window_dpi() runs · Issue #22836 · matplotlib/matplotlib
X Title: [Bug]: TclError raised by _set_image_for_button() when _update_window_dpi() runs · Issue #22836 · matplotlib/matplotlib
Description: Bug summary I was trying to debug #22822 and an unrelated error pops up in _set_image_for_button when moving a window between monitors of different DPIs. It is a Tcl error that pops up during the _update_window_dpi callback and is theref...
Open Graph Description: Bug summary I was trying to debug #22822 and an unrelated error pops up in _set_image_for_button when moving a window between monitors of different DPIs. It is a Tcl error that pops up during the _...
X Description: Bug summary I was trying to debug #22822 and an unrelated error pops up in _set_image_for_button when moving a window between monitors of different DPIs. It is a Tcl error that pops up during the _...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/22836
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: TclError raised by _set_image_for_button() when _update_window_dpi() runs","articleBody":"### Bug summary\r\n\r\nI was trying to debug #22822 and an unrelated error pops up in `_set_image_for_button` when moving a window between monitors of different DPIs. It is a Tcl error that pops up during the `_update_window_dpi` callback and is therefore printed without ending the program.\r\n\r\n### Code for reproduction\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nimport matplotlib\r\nmatplotlib.use('tkagg')\r\n\r\nfig, ax = plt.subplots(1,1)\r\nplt.show()\r\n```\r\n\r\n\r\n### Actual outcome\r\n\r\n```\r\nException in Tkinter callback\r\nTraceback (most recent call last):\r\n File \"C:\\Users\\richa\\miniconda3\\envs\\mpl-dev\\lib\\tkinter\\__init__.py\", line 1921, in __call__\r\n return self.func(*args)\r\n File \"c:\\users\\richa\\documents\\github\\matplotlib\\lib\\matplotlib\\backends\\_backend_tk.py\", line 438, in _update_window_dpi\r\n self.toolbar._rescale()\r\n File \"c:\\users\\richa\\documents\\github\\matplotlib\\lib\\matplotlib\\backends\\_backend_tk.py\", line 574, in _rescale\r\n NavigationToolbar2Tk._set_image_for_button(self, widget)\r\n File \"c:\\users\\richa\\documents\\github\\matplotlib\\lib\\matplotlib\\backends\\_backend_tk.py\", line 674, in _set_image_for_button\r\n button.configure(image=image)\r\n File \"C:\\Users\\richa\\miniconda3\\envs\\mpl-dev\\lib\\tkinter\\__init__.py\", line 1675, in configure\r\n return self._configure('configure', cnf, kw)\r\n File \"C:\\Users\\richa\\miniconda3\\envs\\mpl-dev\\lib\\tkinter\\__init__.py\", line 1665, in _configure\r\n self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))\r\n_tkinter.TclError: image \"pyimage10\" doesn't exist\r\n```\r\n\r\nAlso because the callback is interrupted, some widgets are not rescaled.\r\n\r\n### Expected outcome\r\n\r\nno traceback and properly scaled widgets\r\n\r\n### Additional information\r\n\r\nThis code was introduced in #22163 to improve the Tk toolbar buttons in dark mode situations. I don't immediately see the cause, but it seems very easy for me to trigger so I'm surprised nobody noticed? attn: @daniilS \r\n\r\n### Operating system\r\n\r\nWindows\r\n\r\n### Matplotlib Version\r\n\r\nmain back to ff60b28 (bisected)\r\n\r\n### Matplotlib Backend\r\n\r\ntkagg\r\n\r\n### Python version\r\n\r\n3.10.4\r\n\r\n### Jupyter version\r\n\r\n_No response_\r\n\r\n### Installation\r\n\r\ngit checkout","author":{"url":"https://github.com/richardsheridan","@type":"Person","name":"richardsheridan"},"datePublished":"2022-04-13T01:34:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/22836/matplotlib/issues/22836"}
| 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:5e5a359b-3b60-8e01-08ec-5e4b8ffc8992 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CC60:1FBEDF:D129A4:1191B04:6A516905 |
| html-safe-nonce | 6def08d6a9b0e30e8b174f2e219edd429db43eaf8cfb5f1d5d8903ee42588b4d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzYwOjFGQkVERjpEMTI5QTQ6MTE5MUIwNDo2QTUxNjkwNSIsInZpc2l0b3JfaWQiOiIxNTgwMDQ3NzA2MTAwOTUxMzAxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | dc73b61cc9753999501545d126a600bb667fd48948b0032dced0c8d1d3c2ed98 |
| hovercard-subject-tag | issue:1202641778 |
| 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/22836/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6e710005ff73f912023e59fb05e4e6488356ec7260da6c766663cf454943517d/matplotlib/matplotlib/issues/22836 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6e710005ff73f912023e59fb05e4e6488356ec7260da6c766663cf454943517d/matplotlib/matplotlib/issues/22836 |
| og:image:alt | Bug summary I was trying to debug #22822 and an unrelated error pops up in _set_image_for_button when moving a window between monitors of different DPIs. It is a Tcl error that pops up during the _... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | richardsheridan |
| 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 | 60eaaf6d4dbaa817031b556aebd8a0a7eeb81b97 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width