8000 Merge pull request #21478 from QuLogic/gtk4-embedding · matplotlib/matplotlib@cda9ecc · GitHub
[go: up one dir, main page]

Skip to content

Commit cda9ecc

Browse files
authored
Merge pull request #21478 from QuLogic/gtk4-embedding
Fix GTK4 embedding example
2 parents 7eaf90b + ac12552 commit cda9ecc

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

lib/matplotlib/backends/_backend_gtk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def _create_application():
4343

4444
if _application is None:
4545
app = Gio.Application.get_default()
46-
if app is None or getattr(app, '_created_by_matplotlib'):
46+
if app is None or getattr(app, '_created_by_matplotlib', False):
4747
# display_is_valid returns False only if on Linux and neither X11
4848
# nor Wayland display can be opened.
4949
if not mpl._c_internal_utils.display_is_valid():

lib/matplotlib/backends/backend_gtk3agg.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ def blit(self, bbox=None):
7070
self.queue_draw_area(x, y, width, height)
7171

7272
def draw(self):
73+
# Call these explicitly because GTK's draw is a GObject method which
74+
# isn't cooperative with Python class methods.
7375
backend_agg.FigureCanvasAgg.draw(self)
74-
super().draw()
76+
backend_gtk3.FigureCanvasGTK3.draw(self)
7577

7678

7779
class FigureManagerGTK3Agg(backend_gtk3.FigureManagerGTK3):

lib/matplotlib/backends/backend_gtk4agg.py

Lines changed: 4 additions & 2 deletions
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)
@@ -38,8 +38,10 @@ def on_draw_event(self, widget, ctx):
3838
return False
3939

4040
def draw(self):
41+
# Call these explicitly because GTK's draw is a GObject method which
42+
# isn't cooperative with Python class methods.
4143
backend_agg.FigureCanvasAgg.draw(self)
42-
super().draw()
44+
backend_gtk4.FigureCanvasGTK4.draw(self)
4345

4446

4547
class FigureManagerGTK4Agg(backend_gtk4.FigureManagerGTK4):

0 commit comments

Comments
 (0)
0