for i in range(len(trgx)):
qp.begin(self)
brush = QtGui.QBrush(QtCore.Qt.red,QtCore.Qt.SolidPattern)
qp.setBrush(brush)
qp.drawRect(trgx[i],trgy[i],cd,rd)
qp.end()
time.sleep(.4)
the above code is part of the paintEvent, The problem here is that the painting does not occur rectangle by rectangle, but instead it waits for the entire sleep to finish ie sleep(.4)*len(trgx) and then prints all the rectangles together.How do I rectify this ??
I think that you cannot pause the paintEvent and have the screen updated at the same time.
To do what you want, a possible way is to create a method that call the paintEvent passing the number of rectangle to draw and then pause.
Probably a better method is to use a QTimer with a code like this (pseudocode):
timer = QTimer()
connect(timer, SIGNAL(timeout()), this, SLOT(update()))
timer.start(1000)
the update()
slot calculate the number of rectangle to draw and draw them. When all the rectangles are drawn, just call the timer.stop()
method to stop the timer.