Skip to content
Related Articles

Related Articles

PyQt5 – Visibility status of Status Bar

View Discussion
Improve Article
Save Article
  • Last Updated : 26 Mar, 2020

Visibility status of status bar can be referred as if it is visible then it will return True, else False. We can check it by using isVisible method.

Syntax : class_object.status_bar_object.isVisible()

Argument : It takes no parameter.

Return : It return bool.

Note #1: If we don’t create a object of status bar this property will be false.
Note #2: If this method is called inside the constructor, it will always return False, as before showing anything every visible status is False.

Code :




from PyQt5.QtCore import * 
from PyQt5.QtGui import * 
from PyQt5.QtWidgets import * 
import sys
  
  
class Window(QMainWindow):
    def __init__(self):
        super().__init__()
  
        # set the title
        self.setWindowTitle("Python")
  
        # setting  the geometry of window
        self.setGeometry(60, 60, 600, 400)
  
        # setting status bar message
        self.statusBar().showMessage("This is status bar")
  
        # setting  border
        self.statusBar().setStyleSheet("border :3px solid black;")
  
        # setting tool tip for status bar
        self.statusBar().setToolTip("Hello ! from status bar")
  
        # creating a label widget
        self.label_1 = QLabel("status bar", self)
  
        # moving position
        self.label_1.move(100, 100)
  
        # setting up the border
        self.label_1.setStyleSheet("border :1px solid blue;")
  
        # resizing label
        self.label_1.adjustSize()
  
        # show all the widgets
        self.show()
  
  
# create pyqt5 app
App = QApplication(sys.argv)
  
# create the instance of our Window
window = Window()
  
# getting visibility status
t = window.statusBar().isVisible()
  
# printing value of t
print(t)
  
# start the app
sys.exit(App.exec())

Output :

True


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!