<s> from . QtCore import QObject , QEvent , Slot <EOL> from . QtGui import QPainter , QPixmap <EOL> class QPixmapPainter ( QObject ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( QPixmapPainter , self ) . __init__ ( ) <EOL> self . _target = None <EOL> self . _pixmap = None <EOL> @ Slot ( QPixmap ) <EOL> def drawPixmap ( self , pixmap ) : <EOL> """<STR_LIT>""" <EOL> self . _pixmap = pixmap <EOL> target = self . _target <EOL> if target is not None : <EOL> target . update ( ) <EOL> def targetWidget ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _target <EOL> def setTargetWidget ( self , widget ) : <EOL> """<STR_LIT>""" <EOL> old = self . _target <EOL> if old is not None : <EOL> old . removeEventFilter ( self ) <EOL> if widget is not None : <EOL> widget . installEventFilter ( self ) <EOL> self . _target = widget <EOL> def eventFilter ( self , obj , event ) : <EOL> """<STR_LIT>""" <EOL> if event . type ( ) == QEvent . Paint : <EOL> if obj is self . _target : <EOL> pm = self . _pixmap <EOL> if pm is not None : <EOL> painter = QPainter ( obj ) <EOL> painter . drawPixmap ( <NUM_LIT:0> , <NUM_LIT:0> , pm ) <EOL> return True <EOL> return False </s>
