Open romanrdgz opened 6 years ago
After looking at the original C++ QtWaitingSpinner code, I also don't think that modal thing worked there.
You can patch it locally for now, so it kind of works.
diff --git a/waitingspinnerwidget.py b/waitingspinnerwidget.py
index 12f273b..8573ef5 100644
--- a/waitingspinnerwidget.py
+++ b/waitingspinnerwidget.py
@@ -34,7 +34,7 @@ from PyQt5.QtWidgets import *
class QtWaitingSpinner(QWidget):
def __init__(self, parent, centerOnParent=True, disableParentWhenSpinning=False, modality=Qt.NonModal):
- super().__init__(parent)
+ super().__init__(parent, Qt.Dialog | Qt.FramelessWindowHint)
self._centerOnParent = centerOnParent
self._disableParentWhenSpinning = disableParentWhenSpinning
@@ -187,8 +187,11 @@ class QtWaitingSpinner(QWidget):
def updatePosition(self):
if self.parentWidget() and self._centerOnParent:
- self.move(self.parentWidget().width() / 2 - self.width() / 2,
- self.parentWidget().height() / 2 - self.height() / 2)
+# dialogCenter = self.mapToGlobal(self.rect().center());
+# parentWindowCenter = self.parentWidget().window().mapToGlobal(self.parentWidget().window().rect().center())
+# self.move(parentWindowCenter - dialogCenter)
+ parentRect = QRect(self.parentWidget().mapToGlobal(QPoint(0, 0)), self.parentWidget().size())
+ self.move(QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(), parentRect).topLeft())
def lineCountDistanceFromPrimary(self, current, primary, totalNrOfLines):
distance = primary - current
But also in your example, somehow the urllib request is blocking the QTimer in the waiting spinner so it doesn't show at all. If you remove that call (and the calls to stop the spinner and close the window) and apply the patch above you should see the spinner spinning.
It works now, but you are right: it doesn't work with urllib, don't know why.
It seems someone fixed it in Stackoverflow: https://stackoverflow.com/questions/52313073/making-an-invisible-layer-in-pyqt-which-covers-the-whole-diaglo/52316134#52316134
I have a QDialog with QTabWidget. Using the alternative example, I was somehow expecting the spinner to appear as an overlay, over the tabs, centered in the parent widget (the QDialog). Nevertheless, it doesn't show up.
This is a short example of downloading a file and expecting the spinner to show up:
Am I doing something wrong?