When running a test doc build for 3.7.0rc1, I build the PDF, which runs everything with the PDF backend. So either the PDF backend does not correctly mark itself as not supporting blitting, or the blitting is not turned off correctly in the button widgets.
Code for reproduction
make-Cdoclatexpdf
Actual outcome
/home/elliott/code/matplotlib-3.7.x/doc/users/next_whats_new/widget_button_styling.rst:8: WARNING: Exception occurred in plotting widget_button_styling-1
from /home/elliott/code/matplotlib-3.7.x/doc/users/next_whats_new/widget_button_styling.rst:
Traceback (most recent call last):
File "/home/elliott/code/matplotlib-3.7.x/lib/matplotlib/sphinxext/plot_directive.py", line 615, in render_figures
figman.canvas.figure.savefig(img.filename(fmt), dpi=dpi)
File "/home/elliott/code/matplotlib-3.7.x/lib/matplotlib/figure.py", line 3328, in savefigself.canvas.print_figure(fname, **kwargs)
File "/home/elliott/code/matplotlib-3.7.x/lib/matplotlib/backend_bases.py", line 2362, in print_figure
result = print_method(
^^^^^^^^^^^^^
File "/home/elliott/code/matplotlib-3.7.x/lib/matplotlib/backend_bases.py", line 2228, in <lambda>
print_method = functools.wraps(meth)(lambda*args, **kwargs: meth(
^^^^^
File "/home/elliott/code/matplotlib-3.7.x/lib/matplotlib/backends/backend_pdf.py", line 2815, in print_pdfself.figure.draw(renderer)
File "/home/elliott/code/matplotlib-3.7.x/lib/matplotlib/artist.py", line 95, in draw_wrapper
result = draw(artist, renderer, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/elliott/code/matplotlib-3.7.x/lib/matplotlib/artist.py", line 72, in draw_wrapperreturn draw(artist, renderer)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/elliott/code/matplotlib-3.7.x/lib/matplotlib/figure.py", line 3135, in draw
DrawEvent("draw_event", self.canvas, renderer)._process()
File "/home/elliott/code/matplotlib-3.7.x/lib/matplotlib/backend_bases.py", line 1259, in _processself.canvas.callbacks.process(self.name, self)
File "/home/elliott/code/matplotlib-3.7.x/lib/matplotlib/cbook/__init__.py", line 309, in processself.exception_handler(exc)
File "/home/elliott/code/matplotlib-3.7.x/lib/matplotlib/cbook/__init__.py", line 96, in _exception_printerraise exc
File "/home/elliott/code/matplotlib-3.7.x/lib/matplotlib/cbook/__init__.py", line 304, in process
func(*args, **kwargs)
File "/home/elliott/code/matplotlib-3.7.x/lib/matplotlib/widgets.py", line 1706, in _clearself.ax.draw_artist(self._buttons)
File "/home/elliott/code/matplotlib-3.7.x/lib/matplotlib/axes/_base.py", line 3076, in draw_artist
a.draw(self.figure.canvas.get_renderer())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^AttributeError: 'FigureCanvasPdf' object has no attribute 'get_renderer'
Further investigation shows that this is not directly about the PDF backend. Rather, it occurs when changing to the PDF backend to save as a .pdf. If you start directly with the PDF backend, then the Widget will see that the canvas doesn't support blitting and disable it. So this might affect anything which uses blitting, depending on what they do.
Activity
QuLogic commented on Jan 25, 2023
Further investigation shows that this is not directly about the PDF backend. Rather, it occurs when changing to the PDF backend to save as a .pdf. If you start directly with the PDF backend, then the Widget will see that the canvas doesn't support blitting and disable it. So this might affect anything which uses blitting, depending on what they do.
QuLogic commented on Jan 25, 2023
Defining get_renderer like this seems to work:
Not sure if that's the best fix though.
FIX: only try to update blit caches if the canvas we expect
FIX: only try to update blit caches if the canvas we expect
FIX: only try to update blit caches if the canvas we expect