Any PyQt circular progress bar?

前端 未结 3 1305
故里飘歌
故里飘歌 2021-01-07 15:07

Does anybody know how I can implement circular progress bar on PyQt?

Also, I found an existing code: http://sourceforge.net/projects/qroundprogressbar/

But,

3条回答
  •  孤城傲影
    2021-01-07 15:51

    I have write this

    class RoundProgress(QProgressBar):
    def __init__(self,parent):
        QProgressBar.__init__(self)
        self.values = self.value()
        self.values = (self.values*360)/100
        self.parent = parent
        self.setParent(parent)
        self.n = self.value()
        self.label = QLabel("
    100%
    ") self.label.setStyleSheet("color:red;") self.label.setFont(QFont("courrier",math.sqrt(self.width()))) self.v = QVBoxLayout(self) self.setLayout(self.v) self.v.addWidget(self.label) def setValue(self,n): self.n = n self.values = ((n*5650)/100)*(-1) self.label.setText("
    "+str(self.n)+"
    ") def setNvalue(self,n): self.n = n self.values = ((n*5650)/100)*(-1) self.label.setText("
    "+str(self.n)+"
    ") def paintEvent(self,event): painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing) pen = QPen() pen.setWidth(2) pen.setColor(QColor("darkblue")) painter.setPen(pen) pen = QPen() pen.setWidth(9) pen.setColor(QColor("lightgrey")) painter.setPen(pen) painter.drawArc(5.1,5.1,self.width()-10,self.height()-10,1450,-5650) #painter.drawEllipse(0,0,100,100) painter.setBrush(QColor("lightblue")) pen = QPen() pen.setWidth(10) pen.setColor(QColor("red")) painter.setPen(pen) painter.drawArc(5.1,5.1,self.width()-10,self.height()-10,1450,self.values) self.update()

提交回复
热议问题