Open In App
Related Articles

PyQt5 – Set tool tip to Status Bar

Improve Article
Save Article
Like Article

In this article we will see how we can set tool tip to a status bar. The tooltip or infotip or a hint is a common graphical user interface element. It is used in conjunction with a cursor, usually a pointer. The user hovers the pointer over an item, without clicking it, and a tooltip may appear—a small “hover box” with information about the item being hovered over.

In order to set this we will use setToolTip method with status bar object.

Syntax : self.statusBar().setToolTip(data)

Argument : It takes string as argument.

Action performed : It sets tool tip to status bar.

Code :

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 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
        # show all the widgets
# create pyqt5 app
App = QApplication(sys.argv)
# create the instance of our Window
window = Window()
# start the app

Output :

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 26 Mar, 2020
Like Article
Save Article
Similar Reads
Complete Tutorials