生活会辜负努力的人,但不会辜负一直努力的人

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

效果如下(由于不方便截图,就另存了教程中的图片):

                               (加上提示信息即为实际截图)

 

 1 """
 2 This example shows a tooltip on
 3 a window and a button.
 4 """
 5 import sys
 6 from PyQt5.QtWidgets import (QWidget, QToolTip, QPushButton, QApplication)
 7 from PyQt5.QtGui import QFont
 8 
 9 
10 class Example(QWidget):
11 
12     def __init__(self):
13         super().__init__()
14         self.initUI()
15 
16     def initUI(self):
17 
18         # We use a 10px SansSerif font.
19         QToolTip.setFont(QFont('SansSerif', 10))
20         # This static method sets a font used to render tooltips.
21 
22         # To create a tooltip, we call the setTooltip() method.
23         self.setToolTip('This is a <b>QWidget</b> widget')
24 
25         # create a push button widget and set a tooltip for it
26         btn = QPushButton('Button', self)
27         btn.setToolTip('This is a <b>QPushButton</b> widget')
28         btn.resize(btn.sizeHint())
29         # The sizeHint() method gives a recommended size for the button
30         
31         btn.move(50, 50)
32 
33         self.setGeometry(300, 300, 300, 200)
34         self.setWindowTitle('Tooltips')
35         self.show()
36 
37 
38 if __name__ == '__main__':
39 
40     app = QApplication(sys.argv)
41     ex = Example()
42     sys.exit(app.exec_())

 

posted on 2018-04-02 21:32  何许亻也  阅读(180)  评论(0编辑  收藏  举报