A tooltip is a message that is shown when hovering the mouse on a widget.

This can be a plain text message or a formatted message (HTML). You can add a tooltip by calling .setToolTip("text") on a widget. This is often used to assist the user.

Download Examples:
Download PyQt examples

Tooltip example

PyQt tooltip example

The program below adds tooltip messages to the buttons. This can be either plain text or HTML formatted tags (the tags bold and italic work).

You can set any message you want inside the tooltip message.

from PyQt5.QtWidgets import *
import sys

class Window(QWidget):

def __init__(self):
layout = QGridLayout()

button = QPushButton("Button")
button.setToolTip("This is a text")
layout.addWidget(button, 0, 0)

button = QPushButton("Button")
button.setToolTip("<b>HTML</b> <i>can</i> be shown too..")
layout.addWidget(button, 1, 0)

app = QApplication(sys.argv)
screen = Window()