Open In App
Related Articles

PyQt5 QProgressBar – How to create progress bar ?

Improve Article
Save Article
Like Article

In this article we will see how we can create the progress bar in PyQt5. In order to create progress bar object we will use QProgressBar.

A progress bar is a graphical control element used to visualize the progression of an extended computer operation, such as a download, file transfer, or installation. Sometimes, the graphic is accompanied by a textual representation of the progress in a percent format.

Syntax :

pbar = QProgressBar(self)

Code :

# importing libraries
from PyQt5.QtWidgets import * 
from PyQt5.QtGui import * 
from PyQt5.QtCore import * 
import sys
import time
class Example(QWidget):
    def __init__(self):
        # calling initUI method
    # method for creating widgets
    def initUI(self):
        # creating progress bar
        self.pbar = QProgressBar(self)
        # setting its geometry
        self.pbar.setGeometry(30, 40, 200, 25)
        # creating push button
        self.btn = QPushButton('Start', self)
        # changing its position
        self.btn.move(40, 80)
        # adding action to push button
        # setting window geometry
        self.setGeometry(300, 300, 280, 170)
        # setting window action
        # showing all the widgets
    # when button is pressed this method is being called
    def doAction(self):
        # setting for loop to set value of progress bar
        for i in range(101):
            # slowing down the loop
            # setting value to progress bar
# main method
if __name__ == '__main__':
    # create pyqt5 app
    App = QApplication(sys.argv)
    # create the instance of our Window
    window = Example()
    # start the app

Output :

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 22 Apr, 2020
Like Article
Save Article
Similar Reads
Complete Tutorials