def paintEvent( self, e ):
<EOL>if DEBUG: print('<STR_LIT>', self,self.get_width_height())<EOL>if type(self.replot) is bool: <EOL><INDENT>if self.replot:<EOL><INDENT>FigureCanvasAgg.draw(self)<EOL><DEDENT>if QtCore.QSysInfo.ByteOrder == QtCore.QSysInfo.LittleEndian:<EOL><INDENT>stringBuffer = self.renderer._renderer.tostring_bgra()<EOL><DEDENT>else:<EOL><INDENT>stringBuffer = self.renderer._renderer.tostring_argb()<EOL><DEDENT>qImage = QtGui.QImage(stringBuffer, self.renderer.width,<EOL>self.renderer.height,<EOL>QtGui.QImage.Format_ARGB32)<EOL>p = QtGui.QPainter(self)<EOL>p.drawPixmap(QtCore.QPoint(<NUM_LIT:0>, <NUM_LIT:0>), QtGui.QPixmap.fromImage(qImage))<EOL>if self.drawRect:<EOL><INDENT>p.setPen( QtGui.QPen( QtCore.Qt.black, <NUM_LIT:1>, QtCore.Qt.DotLine ) )<EOL>p.drawRect( self.rect[<NUM_LIT:0>], self.rect[<NUM_LIT:1>], self.rect[<NUM_LIT:2>], self.rect[<NUM_LIT:3>] )<EOL><DEDENT>p.end()<EOL><DEDENT>else:<EOL><INDENT>bbox = self.replot<EOL>l, b, r, t = bbox.extents<EOL>w = int(r) - int(l)<EOL>h = int(t) - int(b)<EOL>t = int(b) + h<EOL>reg = self.copy_from_bbox(bbox)<EOL>stringBuffer = reg.to_string_argb()<EOL>qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32)<EOL>pixmap = QtGui.QPixmap.fromImage(qImage)<EOL>p = QtGui.QPainter( self )<EOL>p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), pixmap)<EOL>p.end()<EOL><DEDENT>self.replot = False<EOL>self.drawRect = False<EOL>
Draw to the Agg backend and then copy the image to the qt.drawable.
In Qt, all drawing should be done inside of here when a widget is
shown onscreen.