我有一个Web搜寻器脚本,我们称其为scraper.py,它将数据写入数据库。我用显示数据库内容的tableWidget制作了gui。现在,我添加了一个按钮,该按钮将从scraper.py脚本调用main()函数。因为,scraper正在使用硒,大约需要20秒才能完成所有操作(从打开浏览器并关闭它),我希望禁用该按钮(或者可能禁用名为MainWindow的整个表单),直到scraper.py完成。另外,main()函数不一定需要具有“ return 0”语句。
提前致谢。
def fetchFuction():
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
# if incase function failed then restore it
try:
yourFetchFucn()
QtGui.QApplication.restoreOverrideCursor()
except:
QtGui.QApplication.restoreOverrideCursor()
希望这可以帮助
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句