66import os , sys
77
88import matplotlib
9- from matplotlib import verbose
10- from matplotlib .cbook import enumerate
119from matplotlib .figure import Figure
1210
1311from backend_agg import FigureCanvasAgg
@@ -61,7 +59,7 @@ def __init__( self, figure ):
6159 self .drawRect = False
6260 self .rect = []
6361 self .replot = True
64- self .pixmap = QtGui . QPixmap ( )
62+ self .setAttribute ( QtCore . Qt . WA_OpaquePaintEvent )
6563
6664 def resizeEvent ( self , e ):
6765 FigureCanvasQT .resizeEvent ( self , e )
@@ -86,26 +84,25 @@ def paintEvent( self, e ):
8684
8785 # only replot data when needed
8886 if type (self .replot ) is bool : # might be a bbox for blitting
89- if ( self .replot ):
90- #stringBuffer = str( self.buffer_rgba(0,0) )
91- FigureCanvasAgg .draw ( self )
92-
93- # matplotlib is in rgba byte order.
94- # qImage wants to put the bytes into argb format and
95- # is in a 4 byte unsigned int. little endian system is LSB first
96- # and expects the bytes in reverse order (bgra).
97- if ( QtCore .QSysInfo .ByteOrder == QtCore .QSysInfo .LittleEndian ):
98- stringBuffer = self .renderer ._renderer .tostring_bgra ()
99- else :
100- stringBuffer = self .renderer ._renderer .tostring_argb ()
101- qImage = QtGui .QImage ( stringBuffer , self .renderer .width ,
102- self .renderer .height ,
103- QtGui .QImage .Format_ARGB32 )
104- self .pixmap = self .pixmap .fromImage ( qImage )
105- p .drawPixmap ( QtCore .QPoint ( 0 , 0 ), self .pixmap )
87+ if self .replot :
88+ FigureCanvasAgg .draw (self )
89+
90+ # matplotlib is in rgba byte order. QImage wants to put the bytes
91+ # into argb format and is in a 4 byte unsigned int. Little endian
92+ # system is LSB first and expects the bytes in reverse order
93+ # (bgra).
94+ if QtCore .QSysInfo .ByteOrder == QtCore .QSysInfo .LittleEndian :
95+ stringBuffer = self .renderer ._renderer .tostring_bgra ()
96+ else :
97+ stringBuffer = self .renderer ._renderer .tostring_argb ()
98+
99+ qImage = QtGui .QImage (stringBuffer , self .renderer .width ,
100+ self .renderer .height ,
101+ QtGui .QImage .Format_ARGB32 )
102+ p .drawPixmap (QtCore .QPoint (0 , 0 ), QtGui .QPixmap .fromImage (qImage ))
106103
107104 # draw the zoom rectangle to the QPainter
108- if ( self .drawRect ) :
105+ if self .drawRect :
109106 p .setPen ( QtGui .QPen ( QtCore .Qt .black , 1 , QtCore .Qt .DotLine ) )
110107 p .drawRect ( self .rect [0 ], self .rect [1 ], self .rect [2 ], self .rect [3 ] )
111108
@@ -117,8 +114,8 @@ def paintEvent( self, e ):
117114 reg = self .copy_from_bbox (bbox )
118115 stringBuffer = reg .to_string ()
119116 qImage = QtGui .QImage (stringBuffer , w , h , QtGui .QImage .Format_ARGB32 )
120- self . pixmap = self . pixmap .fromImage ( qImage )
121- p .drawPixmap (QtCore .QPoint (l , self .renderer .height - t ), self . pixmap )
117+ pixmap = QtGui . QPixmap .fromImage (qImage )
118+ p .drawPixmap (QtCore .QPoint (l , self .renderer .height - t ), pixmap )
122119
123120 p .end ()
124121 self .replot = False
0 commit comments