PyQt5 – orientation() method Progress Bar
When we create progress bar in PyQt5 its orientation is by default horizontal, but we can change it with the help of setOrientation
method. In order to get the information about the orientation of progress bar i.e it is horizontal or vertical orientation
method is used.
Syntax : bar.orientation()
Argument : It takes no argument.
Return : It will return Orientation object although when we print it, it will print 1 for horizontal orientation and 2 for vertical orientation.
Below is the implementation.
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( 250 , 90 , 30 , 200 )
bar.setValue( 40 )
bar.setAlignment(Qt.AlignCenter)
bar.setOrientation(QtCore.Qt.Vertical)
orientation = bar.orientation()
print ( type (orientation))
print (orientation)
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :
class 'PyQt5.QtCore.Qt.Orientation'
2
Last Updated :
22 Apr, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...