import sys from PyQt5.QtWidgets import QToolTip,QPushButton,QApplication, QHBoxLayout, QMainWindow, QPushButton, QWidget from PyQt5.QtGui import QIcon,QFont class TooltipForm(QMainWindow): def __init__(self): super(TooltipForm,self).__init__() self.initUI() self.button1.clicked.connect(self.onClick_Button) def initUI(self): self.setWindowTitle ( " first application main window " ) self.setGeometry ( 200,200,300,300 ) # status bar self.status = self.statusBar () # Icon self.setWindowIcon (QIcon ( " ./image/lou.ico " )) # set a button and displayed on the screen self.button1 = QPushButton () self.button1.setText ( " Button 1 " ) self.button1.setToolTip ( " Button explained ." ) layout = QHBoxLayout() layout.addWidget(self.button1) # Main frame, to place all controls of the mainFrame = the QWidget () mainFrame.setLayout(layout) # Make full screen self.setCentralWidget (mainFrame) DEF onClick_Button (Self): SENDER = self.sender () # used to determine whether an event is triggered, this refers to whether the button is pressed App = QApplication.instance () # exit the application app.quit () if __name__ == "__main__": app = QApplication(sys.argv) main = TooltipForm () # display window main.show () # established cycle sys.exit (app.exec_ ())