美文网首页
PYQT - QProcess

PYQT - QProcess

作者: 弗兰克万岁 | 来源:发表于2020-02-14 18:09 被阅读0次

    效果:

    image
    # -*- coding: utf-8 -*-
    import sys
    import random
    from PyQt4.QtGui import *
    from PyQt4.QtCore import *
    
    class BaseProgressDialog(QMainWindow):
        def __init__(self, parent=None):
            super(self.__class__, self).__init__(parent)
            self.resize(500, 250)
            w = QWidget()
            self.scroll = QScrollArea() # 滚动条
            self.scroll.setWidgetResizable(True)
            self.scroll.setWidget(w)
            self.setCentralWidget(self.scroll)
    
            self.layout = QVBoxLayout()
            self.layout.setContentsMargins(10, 10, 10, 10)
            self.layout.setAlignment(Qt.AlignTop) 
            # w.setMinimumSize(500,1000)   # 设置显示部件的绝对大小
            w.setLayout(self.layout)
    
        def add(self, text, color, number):
            label = QLabel(self.tr(text))
            label.setStyleSheet("font-weight: bold;")
    
            progressbar=QProgressBar()
            progressbar.setValue(number)
            style = """
                    QProgressBar {
                        border: 2px solid grey;
                        border-radius: 5px;
                        text-align: center;
                    }
                    QProgressBar::chunk {
                        background-color: #%s;
                        width: 20px;
                    }""" % color
            progressbar.setStyleSheet(style)
    
            self.layout.addWidget(label)
            self.layout.addWidget(progressbar)
    
    if __name__  == '__main__':
        app = QApplication(sys.argv)
        progress = BaseProgressDialog()
    
        blue, green = '88B0EB', '37DA7E'
        for i in range(5):
            progress.add('下载',green, random.randint(0,100))
        for j in range(5):   
            progress.add('上传',blue, random.randint(0,100))
    
        progress.show()
        sys.exit(app.exec_())
    
    

    作者:qdsfdhvh
    链接:https://www.jianshu.com/p/34096a8632aa
    来源:简书
    著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

    相关文章

      网友评论

          本文标题:PYQT - QProcess

          本文链接:https://www.haomeiwen.com/subject/nyejfhtx.html