I am running a while loop with some processing in a python-script which I load with mainWindow.To stop UI from freezing, I am using qt-singleshot. Even though the UI is still freezing.
It is possible that you can overwhelm your computer with your loop so that no much time is left for processing GUI events. Loosen up the loop a bit by calling
slicer.app.processEvents() and/or increasing the timer’s timeout to a value that makes the application sufficiently responsive.