PySide / wait or sleep

半城伤御伤魂 提交于 2019-12-06 13:44:20

Don't use sleep. Sleep will only block the active event loop, the user can still click anywhere in the GUI and the events will be delivered delayed after sleep has returned.

If you want to disable user interaction, then disable the widget (and use a timer to reenable it). A simple example in your case could look like this:

...
def main():
    app = QtGui.QApplication(sys.argv)
    ex = Main()
    ex.setEnabled(False)
    QtCore.QTimer.singleShot(4000, lambda: es.setEnabled(True))
    sys.exit(app.exec_())
...
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!