PyQt5 – setInvertedAppearance() method for Progress Bar
Last Updated :
16 Jan, 2023
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
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__()
self .setWindowTitle("Python ")
self .setGeometry( 100 , 100 , 600 , 400 )
self .UiComponents()
self .show()
def UiComponents( self ):
bar = QProgressBar( self )
bar.setGeometry( 200 , 100 , 200 , 30 )
bar.setValue( 70 )
bar.setAlignment(Qt.AlignCenter)
bar.setInvertedAppearance( True )
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...