From 22f3fdf28f9505a56efc739620d6b615947a1054 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 26 Jun 2020 20:02:00 +0200 Subject: [PATCH] Partially fix rubberbanding in GTK3. The code became wrong because of crossed PRs (resulting in assignment in the readonly `ctx` property). Let's make `ctx` an instance attribute again for now, which at least avoids an exception; however the rubberband is invisible for reasons unclear to me. --- lib/matplotlib/backends/backend_gtk3.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/backends/backend_gtk3.py b/lib/matplotlib/backends/backend_gtk3.py index 042ac413921a..31d20f3e6053 100644 --- a/lib/matplotlib/backends/backend_gtk3.py +++ b/lib/matplotlib/backends/backend_gtk3.py @@ -509,7 +509,7 @@ def set_cursor(self, cursor): def draw_rubberband(self, event, x0, y0, x1, y1): # adapted from # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/189744 - self.ctx = self.canvas.get_property("window").cairo_create() + ctx = self.canvas.get_property("window").cairo_create() # todo: instead of redrawing the entire figure, copy the part of # the figure that was covered by the previous rubberband rectangle @@ -522,11 +522,11 @@ def draw_rubberband(self, event, x0, y0, x1, y1): h = abs(y1 - y0) rect = [int(val) for val in (min(x0, x1), min(y0, y1), w, h)] - self.ctx.new_path() - self.ctx.set_line_width(0.5) - self.ctx.rectangle(rect[0], rect[1], rect[2], rect[3]) - self.ctx.set_source_rgb(0, 0, 0) - self.ctx.stroke() + ctx.new_path() + ctx.set_line_width(0.5) + ctx.rectangle(rect[0], rect[1], rect[2], rect[3]) + ctx.set_source_rgb(0, 0, 0) + ctx.stroke() def _update_buttons_checked(self): for name, active in [("Pan", "PAN"), ("Zoom", "ZOOM")]: