如何在PySide中创建或者已经存在旋转对话框,我可以在服务器请求完成时使用它?

时间:2015-02-03 09:57:57

标签: python pyqt pyside

如何创建或已经存在旋转对话框,我可以在服务器请求完成后使用它?我必须下载文件,在那段时间我必须通知用户某些操作正在执行。

1 个答案:

答案 0 :(得分:1)

解决方案1: 还没有尝试过PyQt版本但是你去了: https://github.com/ertanguven/desktop-service/blob/master/pds/qprogressindicator.py

基于:https://github.com/mojocorp/QProgressIndicator

解决方案2: 使用QMovie加载.gif文件

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

解决方案3(这不是您想要的):进度条。 QProgressDialog http://pyqt.sourceforge.net/Docs/PyQt4/qprogressdialog.html

<强>加成: Loader.gif