progress.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:scm-workbench 作者: barry-scott 项目源码 文件源码
def main():
    app = QtWidgets.QApplication( ['fred'] )

    prog = QtWidgets.QProgressBar()
    prog.setMinimum( 0 )
    prog.setMaximum( total )
    prog.setTextVisible( False )
    prog.setMinimumHeight( 50 )

    prog.show()

    layout = QtWidgets.QHBoxLayout( prog )
    label = QtWidgets.QLabel()

    layout.addWidget( label )
    layout.setContentsMargins( 20, 0, 0, 0 )

    def inc():
        print( 'inc' )
        global count
        if count == total:
            timer.stop()

        else:
            count += 1
            prog.setValue( count )

    def setProgresLabel( self ):
        label.setText( '%3d%%' % (100 * count / total) )

    prog.valueChanged.connect( setProgresLabel )

    timer = QtCore.QTimer()
    timer.setInterval( 250 )
    timer.timeout.connect( inc )
    timer.start()

    app.exec_()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号