You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 therefore printed without ending the program.
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\richa\miniconda3\envs\mpl-dev\lib\tkinter\__init__.py", line 1921, in __call__
return self.func(*args)
File "c:\users\richa\documents\github\matplotlib\lib\matplotlib\backends\_backend_tk.py", line 438, in _update_window_dpi
self.toolbar._rescale()
File "c:\users\richa\documents\github\matplotlib\lib\matplotlib\backends\_backend_tk.py", line 574, in _rescale
NavigationToolbar2Tk._set_image_for_button(self, widget)
File "c:\users\richa\documents\github\matplotlib\lib\matplotlib\backends\_backend_tk.py", line 674, in _set_image_for_button
button.configure(image=image)
File "C:\Users\richa\miniconda3\envs\mpl-dev\lib\tkinter\__init__.py", line 1675, in configure
return self._configure('configure', cnf, kw)
File "C:\Users\richa\miniconda3\envs\mpl-dev\lib\tkinter\__init__.py", line 1665, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: image "pyimage10" doesn't exist
Also because the callback is interrupted, some widgets are not rescaled.
Expected outcome
no traceback and properly scaled widgets
Additional information
This 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
Thanks for spotting this! I think it's because for a checkbutton, changing the image option also re-initialisesselectimage. However, when creating the new images, we overwrite the reference to the previously used selectimage, so it's already been garbage collected. Setting image and selectimage at the same time should fix it, see #22841.
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 therefore printed without ending the program.Code for reproduction
Actual outcome
Also because the callback is interrupted, some widgets are not rescaled.
Expected outcome
no traceback and properly scaled widgets
Additional information
This 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
Operating system
Windows
Matplotlib Version
main back to ff60b28 (bisected)
Matplotlib Backend
tkagg
Python version
3.10.4
Jupyter version
No response
Installation
git checkout
The text was updated successfully, but these errors were encountered: