Reputation: 1837
def generate_thumb(self):
# -- clear preview image
pixmap = QPixmap(self.nwidth, self.nheight)
pixmap.fill( QColor('#C0C0C0'))
ico = QIcon(pixmap)
self.btn3.setIcon(ico)
self.btn3.show() # still not showing
self.generate_thumbnail()
I want btn3 filled with a grey background visible to the user - and then to start the thumbnail generation (takes 5-10 seconds then the btn3 icon is filled again with the generated thumbnail). When I run the code I don't see the grey background at all, only the new rendered image after the generation is done.
How can I force the gui to refresh or show the grey btn3 icon and then start to generate the the new image?
Upvotes: 1
Views: 169
Reputation: 1837
I just finally found the answer myself.
calling QtGui.qApp.processEvents()
worked for me
def generate_thumb(self):
# -- clear preview image
pixmap = QPixmap(self.nwidth, self.nheight)
pixmap.fill( QColor('#C0C0C0'))
ico = QIcon(pixmap)
self.btn3.setIcon(ico)
# show it now!
QtGui.qApp.processEvents()
self.generate_thumbnail()
Upvotes: 1