<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def paint(self, p, *args):
        '''
        I have no idea why, but we need to generate the picture after painting otherwise 
        it draws incorrectly.  
        '''
        if self.picturenotgened:
            self.generatePicture(self.getBoundingParents()[0].rect())
            self.picturenotgened = False
        pg.ImageItem.paint(self, p, *args)
        self.generatePicture(self.getBoundingParents()[0].rect())