setToolTip method in PyQt5

setToolTip() method is used to setting up a tooltip of a widget in PyqT5 application.

A tooltip is a hint in a desktop application (graphical user interface). Tooltips frequently appear when mouse hover over a widget without clicking it. Sometimes, when mouse arrow is held on the button it shows some information that information is a tooltip message.

Syntax : widget.setToolTip(Message)

Argument : It takes string as argument.

Below is the implementation of this method.



filter_none

edit
close

play_arrow

link
brightness_4
code

# importing the required libraries
from PyQt5.QtGui import * 
from PyQt5.QtWidgets import * 
import sys
  
class Window(QMainWindow):
    def __init__(self):
        super().__init__()
  
        # set the title
        self.setWindowTitle("Tooltip")
  
        # set the geometry
        self.setGeometry(0, 0, 300, 300)
  
        # creating a button widget
        self.widget = QPushButton('Widget', self)
  
        # setting up the tooltip
        self.widget.setToolTip("This is a button widget !")
          
        # show all the widgets
        self.show()
  
  
  
# create pyqt5 app
App = QApplication(sys.argv)
  
# create the instance of our Window
window = Window()
  
# start the app
sys.exit(App.exec())

chevron_right


Output :
tooltip-pyqt

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.