进度条QProgressBar

继承于 QWidgetapp

提供一个水平或垂直进度条   进度条用于向用户提供操做进度的指示,并向他们保证应用程序仍在运行ide

 样式:orm

 

 

 
import sysfrom PyQt5.QtWidgets import QApplication, QWidget,QProgressBarfrom PyQt5.QtCore import Qtclass Demo(QWidget):    def __init__(self):        super().__init__()        self.resize(300,350)        self.prb=QProgressBar(self)        self.prb.move(10,10)        self.prb.resize(280,20)        self.prb.setMinimum(50)  #设置最小值-默认0        #minimum() -> int  返回最小值        self.prb.setMaximum(250)  #设置最大值--默认100        #maximum() -> int   返回最大值        self.prb.setRange(100,300)  #设置区间-最小值 最大值        #setRange(0,0)  进入繁忙提示        self.prb.setValue(200)  #设置当前值        #返回当前值        #self.prb.reset()  #重置        #不改变区间值--不改变最小值最大值,把当前值改成最小值-1        self.prb.setFormat('百分比 %p%')        #%p   百分比        #%v  当前值        #%m  总值=最大值-最小值        #format() -> str   返回格式        #resetFormat()  重置格式--默认的百分比        self.prb.setAlignment(Qt.AlignCenter) #格式字符串位置        #Qt.AlignRight   右边        #Qt.AlignCenter  居中        self.prb.setTextVisible(True)  #文本是否可见        s=self.prb.text()  #返回文本        self.prb.setOrientation(Qt.Horizontal)  # 设置进度条方向        # Qt.Horizontal  水平方向--默认        # Qt.Vertical    垂直方向        #self.prb.resize(20,300)        self.prb.setTextDirection(QProgressBar.TopToBottom)  #设置文本方向        #    BottomToTop = 1--默认        #      TopToBottom = 0        #仅仅对于垂直进度条有效        #此语句无效果 ????????????????????        self.prb.setInvertedAppearance(True)  #是否倒立外观        #从左到右变成从右到左        #从下到上变成从上到下        #信号        #valueChanged(int)   值发生变化时发出信号        print(s)if __name__ == '__main__':    app = QApplication(sys.argv)    ex = Demo()    ex.show()    sys.exit(app.exec_())