我想在pyqt5应用程序中执行任务时显示微调器。我发现了微调器的这个很好的实现,所以我尝试了:https://github.com/z3ntu/QtWaitingSpinner
演示工作正常,但在演示中,微调器显示在对话框的空白区域。我希望它是一个覆盖整个对话框的覆盖。在
QtWaitingSpinner的作者建议“作为一个替代的例子,下面的代码将创建一个微调器:(1)只要微调器处于活动状态,它就会阻止所有用户输入到主应用程序;(2)每次调用“start”时,都会自动将自己集中在其父控件上;(3)使用默认形状,“大小和颜色设置。”并使用以下代码:
spinner = QtWaitingSpinner(self, True, True, Qt.ApplicationModal)
spinner.start() # starts spinning
但我尝试了这个实现作为一个例子,但没有成功:
^{pr2}$所以我的目的是创建一个不可见的层,将微调器设置为它唯一的小部件,并在整个对话框窗口中显示半透明层。在
你知道我该怎么做吗?在
一旦我也遇到了这个问题,所以我修改了库,首先激活标志:
QtCore.Qt.Dialog | QtCore.Qt.FramelessWindowHint
,其他更改必须在updatePosition()方法中完成:结果如下:
waitingspinnerwidget.py
^{pr2}$通过上面的方法,我们解决了其中一个问题,另一个问题是
urllib.request.urlretrieve()
阻塞,因此它将导致GUI冻结,因此解决方案是将其移动到另一个线程,使用以前的响应,我们可以按以下方式执行:相关问题 更多 >
编程相关推荐