Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f012adc

Browse files
committed
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.
1 parent 45d27c9 commit f012adc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ def set_cursor(self, cursor):
509509
def draw_rubberband(self, event, x0, y0, x1, y1):
510510
# adapted from
511511
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/189744
512-
self.ctx = self.canvas.get_property("window").cairo_create()
512+
self._ctx = self.canvas.get_property("window").cairo_create()
513513

514514
# todo: instead of redrawing the entire figure, copy the part of
515515
# the figure that was covered by the previous rubberband rectangle
@@ -522,11 +522,11 @@ def draw_rubberband(self, event, x0, y0, x1, y1):
522522
h = abs(y1 - y0)
523523
rect = [int(val) for val in (min(x0, x1), min(y0, y1), w, h)]
524524

525-
self.ctx.new_path()
526-
self.ctx.set_line_width(0.5)
527-
self.ctx.rectangle(rect[0], rect[1], rect[2], rect[3])
528-
self.ctx.set_source_rgb(0, 0, 0)
529-
self.ctx.stroke()
525+
self._ctx.new_path()
526+
self._ctx.set_line_width(0.5)
527+
self._ctx.rectangle(rect[0], rect[1], rect[2], rect[3])
528+
self._ctx.set_source_rgb(0, 0, 0)
529+
self._ctx.stroke()
530530

531531
def _update_buttons_checked(self):
532532
for name, active in [("Pan", "PAN"), ("Zoom", "ZOOM")]:

0 commit comments

Comments
 (0)