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

Skip to content

Commit 069f78e

Browse files
committed
backend_gtk: don't use idle events for draw_rubberband.
Use of idle events for draw_rubberband was a peculiarity of backend_gtk. When using zoom-to-rect, it often caused a rubberband draw event to occur after the canvas redraw at the end of the zoom, leaving the canvas showing the state before the zoom action instead of showing the result of the action. svn path=/trunk/matplotlib/; revision=8466
1 parent 55f052f commit 069f78e

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

lib/matplotlib/backends/backend_gtk.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -611,11 +611,9 @@ def __init__(self, canvas, window):
611611
self.win = window
612612
gtk.Toolbar.__init__(self)
613613
NavigationToolbar2.__init__(self, canvas)
614-
self._idle_draw_id = 0
615614

616615
def set_message(self, s):
617-
if self._idle_draw_id == 0:
618-
self.message.set_label(s)
616+
self.message.set_label(s)
619617

620618
def set_cursor(self, cursor):
621619
self.canvas.window.set_cursor(cursord[cursor])
@@ -644,7 +642,8 @@ def draw_rubberband(self, event, x0, y0, x1, y1):
644642
h = abs(y1 - y0)
645643

646644
rect = [int(val)for val in min(x0,x1), min(y0, y1), w, h]
647-
try: lastrect, imageBack = self._imageBack
645+
try:
646+
lastrect, imageBack = self._imageBack
648647
except AttributeError:
649648
#snap image back
650649
if event.inaxes is None:
@@ -655,16 +654,9 @@ def draw_rubberband(self, event, x0, y0, x1, y1):
655654
b = int(height)-(b+h)
656655
axrect = l,b,w,h
657656
self._imageBack = axrect, drawable.get_image(*axrect)
658-
drawable.draw_rectangle(gc, False, *rect)
659-
self._idle_draw_id = 0
660657
else:
661-
def idle_draw(*args):
662-
drawable.draw_image(gc, imageBack, 0, 0, *lastrect)
663-
drawable.draw_rectangle(gc, False, *rect)
664-
self._idle_draw_id = 0
665-
return False
666-
if self._idle_draw_id == 0:
667-
self._idle_draw_id = gobject.idle_add(idle_draw)
658+
drawable.draw_image(gc, imageBack, 0, 0, *lastrect)
659+
drawable.draw_rectangle(gc, False, *rect)
668660

669661

670662
def _init_toolbar(self):

0 commit comments

Comments
 (0)