• 进度对话框QProgressDialog


    继承于  QDialog

    import sys,time
    from PyQt5.QtWidgets import QApplication, QWidget,QPushButton,QProgressDialog
    
    class Demo(QWidget):
        def __init__(self):
            super().__init__()
            self.resize(300,300)
            pb=QPushButton('按钮',self)
            pb.move(100,250)
            pb.clicked.connect(self.AA)
    
            self.pd=QProgressDialog('进度提示','取消',1,200,self)  #创建进度对话框
            #能自动弹出--要最小展示时长之后;也可以用指令展示
            #进度条走满时默认自动关闭
            #参数1 提示文本
            #参数2 按钮文本
            #参数3和参数4  进度条的最小值和最大值
    
            self.pd.canceled.connect(self.BB)  #取消时发出的信号
    
            self.pd.setMinimumDuration(3)  #设置最小展示时长
            #在规定时间内进度条走满了就不展示了,没有走满就展示
    
            s=self.pd.minimumDuration()  #返回最小展示时长
            print(s)
    
            self.pd.setAutoClose(False)  #进度条走满时是否自动关闭
            #True 自动关闭--默认
            #要自动关闭的条件:setAutoReset必须为True
            #autoClose()   返回是否自动关闭
    
            self.pd.setAutoReset(False)  #是否自动重置
            #False  不重置--进度条走满时,当前值不返回最小值
            #True   默认
            #autoReset()   返回是否自动重置
    
            #reset()  重置
    
            self.pd.setMinimum(0)  #最小值
            self.pd.setMaximum(200)  #最大值
            self.pd.setRange(0,200)  #最小值和最大值
    
            for i in range(0,201):
                self.pd.setValue(i)
                time.sleep(0.01)
                
    
        def AA(self):
            #self.pd.setValue(30)  #设置当前值
            s=self.pd.value()  #返回当前值
            #self.pd.setLabelText('xxx')  #设置提示文本
            #s=self.pd.labelText()  #返回提示文本
    
            #self.pd.setCancelButtonText('取消按钮')  #按钮文本
    
            s=self.pd.wasCanceled()  #返回是否已经取消
    
            #self.pd.cancel()   取消
    
            print(s)
            pass
    
        def BB(self):
            print('取消了')
    
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        demo = Demo()
        demo.show()
        sys.exit(app.exec_())

     

    天子骄龙

  • 相关阅读:
    CAN总线(1)--初探(更新中)
    无约束时钟导致综合实现效果不一致
    推荐几本FPGA书籍(更新中)
    Ubuntu下配置支持Windows访问的Samba共享
    svn 节点处冲突 解决
    clock()、time()、clock_gettime()和gettimeofday()函数的用法和区别
    Linux入门,这七大习惯得有!
    Ubuntu硬盘空间不足时,添加硬盘的方法
    让你快速学会Shell脚本
    printf与fprintf函数的区别
  • 原文地址:https://www.cnblogs.com/liming19680104/p/11096430.html
Copyright © 2020-2023  润新知