显示控件提示消息(ToolTip)
作者:互联网
案例
# 显示控件提示消息 import sys from PyQt5.QtWidgets import QHBoxLayout,QMainWindow,QApplication,QToolTip,QPushButton,QWidget from PyQt5.QtGui import QFont class TooltipForm(QMainWindow): def __init__(self): super().__init__() self.initUI() def initUI(self): QToolTip.setFont(QFont('SansSerif',12)) self.setToolTip('今天是<b>星期五</b>') self.setGeometry(300,30,200,300) self.setWindowTitle('设置控件提示消息') self.button1 = QPushButton('我的按钮') self.button1.setToolTip('这是一个按钮,Are you ok?') layout = QHBoxLayout() layout.addWidget(self.button1) mainFrame = QWidget() mainFrame.setLayout(layout) self.setCentralWidget(mainFrame) if __name__ == '__main__': app = QApplication(sys.argv) main = TooltipForm() main.show() sys.exit(app.exec_())
标签:__,控件,layout,提示,self,ToolTip,mainFrame,import 来源: https://www.cnblogs.com/luweiweicode/p/14693652.html