Update (repaint) application window (python)
-
27-10-2019 - |
Pergunta
LS, I am developping an app that reads text from a web page. While the text is processed in the app the app window (gui) shows "application is not responding" (translated from a Dutch warning message). However the app is not frozen because I see it prints in the console window. The app gui is designed in Qt designer and converted in python 2.7 code on win7 64 bit. How can I force the app to refresh the window and update ? Thanks
Solução
Here are some ways of doing it:
Call your time consuming function in separate
thread
or createtimer
. Basic example withQTimer.singleShot
:QTimer.singleShot(1, your_time_consuming_function)
Call
QCoreApplication.processEvents()
in your text processing loop.
If all the time is spent in fetching the page, consider using timer or thread.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow