import PyQt5.QtWidgets as QtWidgets app = QtWidgets.QApplication([]) widget = QtWidgets.QWidget() layout = QtWidgets.QVBoxLayout(widget) action = QtWidgets.QAction("Click me", widget) action.setStatusTip("Tooltip text for the action") toolbar = QtWidgets.QToolBar() toolbar.addAction(action) layout.addWidget(toolbar) widget.show() app.exec_()
import PyQt5.QtWidgets as QtWidgets app = QtWidgets.QApplication([]) widget = QtWidgets.QWidget() layout = QtWidgets.QVBoxLayout(widget) menu_bar = QtWidgets.QMenuBar() file_menu = menu_bar.addMenu("File") new_action = QtWidgets.QAction("New", widget) open_action = QtWidgets.QAction("Open", widget) save_action = QtWidgets.QAction("Save", widget) new_action.setStatusTip("Create a new file") open_action.setStatusTip("Open an existing file") save_action.setStatusTip("Save the current file") file_menu.addAction(new_action) file_menu.addAction(open_action) file_menu.addAction(save_action) layout.addWidget(menu_bar) widget.show() app.exec_()In this example, we create a QMenuBar with a "File" menu. We create three QActions for "New", "Open", and "Save" and set tooltips for each using setStatusTip. We add the actions to the File menu and show the widget. Overall, we can use the PyQt5.Qt package and its QAction class to create GUIs with various actions and tooltips set using setStatusTip.