0

How to create or is there already spinning dialog which I can use while my request from server is finished ? I have to download file and in that time I have to notify user that some action is executing.

PaolaJ.
  • 10,872
  • 22
  • 73
  • 111

1 Answers1

2

Solution 1: Havn't tried the PyQt version yet but here you go : https://github.com/ertanguven/desktop-service/blob/master/pds/qprogressindicator.py

Which is based on : https://github.com/mojocorp/QProgressIndicator

Solution 2: Using QMovie to load a .gif file

class ImagePlayer(QtGui.QWidget):
    def __init__(self, filename, title, parent=None):
        QtGui.QWidget.__init__(self, parent)

        # Load the file into a QMovie
        self.movie = QtGui.QMovie(filename, QByteArray(), self)

        size = self.movie.scaledSize()
        self.setGeometry(200, 200, size.width(), size.height())
        self.setWindowTitle(title)

        self.movie_screen = QtGui.QLabel()
        # Make label fit the gif
        self.movie_screen.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.movie_screen.setAlignment(Qt.AlignCenter)

        # Create the layout
        main_layout = QtGui.QVBoxLayout()
        main_layout.addWidget(self.movie_screen)

        self.setLayout(main_layout)

        # Add the QMovie object to the label
        self.movie.setCacheMode(QMovie.CacheAll)
        self.movie.setSpeed(100)
        self.movie_screen.setMovie(self.movie)
        self.movie.start()

def run():
    global my_window
    try:
        my_window.close()
        my_window.deleteLater()
    except: pass
    my_window = ImagePlayer(r'Path/To/loader.gif', "Hello")
    my_window.show()

run()

Source

Solution 3 (this is not what you want): A Progress Bar. QProgressDialog http://pyqt.sourceforge.net/Docs/PyQt4/qprogressdialog.html

Bonus: Loader.gif

DrHaze
  • 1,318
  • 10
  • 22