PyQt5 – Progress Bar description
In this article, we will see how exactly we can set and get the description of the progress bar. The description of the progress bar is basically detailed information of the progress bar like what thing progress bar represent and what formatting and styling we have done, there is no particular format for the description it can be normal casual language.
In order to set the description of progress bar we use setAccessibleDescription method and for getting the description we use accessibleDescription, if no description is set accessibleDescription method will give results as null string.
Syntax :
bar.setAccessibleDescription(info)
bar.accessibleDescription()
Argument :
setAccessibleDescription takes string as argument.
accessibleDescription takes no argument.
Return :
setAccessibleDescription returns None.
accessibleDescription returns string.
Below is the implementation.
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.setAccessibleDescription( "Description of progress bar" )
des = bar.accessibleDescription()
label = QLabel( "Description = " + des, self )
label.adjustSize()
label.move( 200 , 150 )
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :
Last Updated :
18 Dec, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...