另一种选择是在等待时处理Qt事件:
def num(): for i in range(1, 999): print(i) # Sleep five seconds in total for _ in range(5 * 10): # Process events between short sleep periods QtWidgets.QApplication.processEvents() time.sleep(0.1)