Skip to content
Related Articles

Related Articles

PyQt5 – Setting and accessing WHATS THIS help text for Status Bar

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

n PyQt5 there are lots of widgets and bars and when we tend to make an application, we end up putting lots of windows and for each window there exit status bar. Sometimes we can’t remember why this status bar is used and what is this status bar. That’s why for back-end purposes PyQt5 allows us to set help text. In this article we will see how to set and access help text for status bar.

In order to set help text we use setWhatsThis() method and for accessing the help text we use whatsThis() method.

Syntax :


Argument :
setWhatsThis() takes string as argument.
whatsThis() takes no argument.

Return :
setWhatsThis() return None
whatsThis() returns string.


from PyQt5.QtCore import * 
from PyQt5.QtGui import * 
from PyQt5.QtWidgets import * 
import sys
class Window(QMainWindow):
    def __init__(self):
        # set the title
        # 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 help text
        self.statusBar().setWhatsThis("this is help text for status bar")
        # creating a label widget
        self.label_1 = QLabel(self)
        # moving position
        self.label_1.move(100, 100)
        # setting up the border
        self.label_1.setStyleSheet("border :1px solid blue;")
        # accessing help text of status bar
        help = self.statusBar().whatsThis()
        # setting text to label
        # resizing label
        # show all the widgets
# create pyqt5 app
App = QApplication(sys.argv)
# create the instance of our Window
window = Window()
# start the app

Output :

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!