QProgressBar is a widget to show process. You've likely seen it many times during installations.

The widget shows a bar and you can see the percentage completed. You can set its value with the method setValue(). Where 50 would set it to 50%.

QProgressBar

Progressbar

Use the code below to create a progressbar:

self.pbar = QProgressBar(self)
self.pbar.setGeometry(30, 40, 200, 25)

You can set the value with:

self.pbar.setValue(50)

That's all that's needed to create a progressbar.

To update it's value, you can use a QTimer.

from PyQt5.QtCore import QBasicTimer

Call a method every second with these lines:

self.timer = QTimer()        self.timer.timeout.connect(self.handleTimer)
self.timer.start(1000)

Then update the progressbar value:

    def handleTimer(self):
        value = self.pbar.value()
        if value < 100:
            value = value + 1
            self.pbar.setValue(value)
        else:
            self.timer.stop()

progressbar pyqt

Example

Copy the code below to see a progressbar counting from 50% to 100%. The progressbar is updated using the method handleTimer() and a QTimer().

import sys
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import QApplication, QMainWindow, QProgressBar
from PyQt5.QtCore import Qt

class Example(QMainWindow):

    def __init__(self):
        super().__init__()

        self.pbar = QProgressBar(self)
        self.pbar.setGeometry(30, 40, 200, 25)
        self.pbar.setValue(50)

        self.setWindowTitle("QT Progressbar Example")
        self.setGeometry(32,32,320,200)
        self.show()

        self.timer = QTimer()
        self.timer.timeout.connect(self.handleTimer)
        self.timer.start(1000)

    def handleTimer(self):
        value = self.pbar.value()
        if value < 100:
            value = value + 1
            self.pbar.setValue(value)
        else:
            self.timer.stop()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())