10000 Fix (uncatchable) traceback in GTK4 embedding example · matplotlib/matplotlib@43044d9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 43044d9

Browse files
committed
Fix (uncatchable) traceback in GTK4 embedding example
On startup, GTK4 appears to call `draw` earlier, which causes an uncatchable traceback: ``` Traceback (most recent call last): File "lib/matplotlib/backends/backend_gtk4.py", line 203, in _draw_func self.on_draw_event(self, ctx) File "lib/matplotlib/backends/backend_gtk4agg.py", line 30, in on_draw_event np.asarray(self.renderer.buffer_rgba())) AttributeError: 'FigureCanvasGTK4Agg' object has no attribute 'renderer' ``` Since a real draw happens later, we just need to be sure a renderer exists at this time.
1 parent 3bcc18a commit 43044d9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/matplotlib/backends/backend_gtk4agg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def on_draw_event(self, widget, ctx):
2727
ctx = backend_cairo._to_context(ctx)
2828

2929
buf = cbook._unmultiplied_rgba8888_to_premultiplied_argb32(
30-
np.asarray(self.renderer.buffer_rgba()))
30+
np.asarray(self.get_renderer().buffer_rgba()))
3131
height, width, _ = buf.shape
3232
image = cairo.ImageSurface.create_for_data(
3333
buf.ravel().data, cairo.FORMAT_ARGB32, width, height)

0 commit comments

Comments
 (0)
0