PyQt5 – setTextVisible() method for Progress Bar
Last Updated :
16 Sep, 2022
We know when we create a progress bar its shows percentage as well. setTextVisible method is used to set whether the text inside the progress bar should be visible or not visible, if we set it to True it will be visible else it will not be visible.
Syntax : bar.setTextVisible(False) Argument : It takes bool as argument. Action performed : It will set the text to invisible.
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( 150 , 150 , 200 , 30 )
bar.setValue( 40 )
bar.setAlignment(Qt.AlignCenter)
bar.setTextVisible( False )
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :
Share your thoughts in the comments
Please Login to comment...