Open In App

PyQt5 – setInvertedAppearance() method for Progress Bar

Last Updated : 16 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

When we create progress bar in PyQt5 by default the progress i.e the loading goes from left to right, but PyQt5 allows us to change its direction as well with the help of setInvertedAppearance method. It takes bool as argument and make the progress bar inverted. Below is how normal progress bar and inverted progress bar looks like

Syntax : bar.setInvertedAppearance(True) Argument : It takes bool as argument. Action performed : It set the progress bar to inverted appearance.

Python3




# importing libraries
from PyQt5.QtWidgets import *
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
 
 
class Window(QMainWindow):
 
    def __init__(self):
        super().__init__()
 
        # setting title
        self.setWindowTitle("Python ")
 
        # setting geometry
        self.setGeometry(100, 100, 600, 400)
 
        # calling method
        self.UiComponents()
 
        # showing all the widgets
        self.show()
 
    # method for widgets
    def UiComponents(self):
        # creating progress bar
        bar = QProgressBar(self)
 
        # setting geometry to progress bar
        bar.setGeometry(200, 100, 200, 30)
 
        # setting the value
        bar.setValue(70)
 
        # setting alignment to center
        bar.setAlignment(Qt.AlignCenter)
 
        # making progress bar inverted
        bar.setInvertedAppearance(True)
 
App = QApplication(sys.argv)
 
# create the instance of our Window
window = Window()
 
# start the app
sys.exit(App.exec())


Output :



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads