Skip to content

Commit 29a43db

Browse files
committed
Merge pull request #539 from efiring/qt4agg_draw
Qt4agg draw
2 parents d2cba84 + b624546 commit 29a43db

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

lib/matplotlib/backends/backend_qt4agg.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def __init__( self, figure ):
5959
self.drawRect = False
6060
self.rect = []
6161
self.blitbox = None
62-
self.replot = True
6362
self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent)
6463

6564
def drawRectangle( self, rect ):
@@ -69,7 +68,7 @@ def drawRectangle( self, rect ):
6968

7069
def paintEvent( self, e ):
7170
"""
72-
Draw to the Agg backend and then copy the image to the qt.drawable.
71+
Copy the image from the Agg canvas to the qt.drawable.
7372
In Qt, all drawing should be done inside of here when a widget is
7473
shown onscreen.
7574
"""
@@ -78,10 +77,6 @@ def paintEvent( self, e ):
7877
if DEBUG: print 'FigureCanvasQtAgg.paintEvent: ', self, \
7978
self.get_width_height()
8079

81-
if self.replot:
82-
FigureCanvasAgg.draw(self)
83-
self.replot = False
84-
8580
if self.blitbox is None:
8681
# matplotlib is in rgba byte order. QImage wants to put the bytes
8782
# into argb format and is in a 4 byte unsigned int. Little endian
@@ -121,11 +116,13 @@ def paintEvent( self, e ):
121116

122117
def draw( self ):
123118
"""
124-
Draw the figure when xwindows is ready for the update
119+
Draw the figure with Agg, and queue a request
120+
for a Qt draw.
125121
"""
126-
127-
if DEBUG: print "FigureCanvasQtAgg.draw", self
128-
self.replot = True
122+
# The Agg draw is done here; delaying it until the paintEvent
123+
# causes problems with code that uses the result of the
124+
# draw() to update plot elements.
125+
FigureCanvasAgg.draw(self)
129126
self.update()
130127

131128
def blit(self, bbox=None):

0 commit comments

Comments
 (0)