Reputation: 1990
What i am trying to achieve is when user pressed push button, i want to show initially hidden QLabel. However, on that push button i have assigned a heavy duty scanning which takes about 2-3 minutes drive scanning. The QLabel is only appeared after scanning is finish, how do i make it appear once button is clicked and not after everything is done.
The codes
self.label_3.hide()
...
self.pushButton.clicked.connect(self._btn_cb)
...
def _btn_cb(self):
self.label_3.show() # here is the show code
for filename in find_files("C://images//", '*.png'): # took roughly 2-3 minutes
print filename
I am very new to python, thank you for assisting me
Upvotes: 0
Views: 1023
Reputation: 4510
You just need to add a call to
QApplication.instance().processEvents()
Just after you call .show()
on your label. This will force Qt to process events in your queue (showing the label) before it moves on to the rest of the code.
Make sure you import QApplication
from QtGui
at the start of your code.
from PyQt4.QtGui import QApplication
Upvotes: 1