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

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

效果如下图:

 1 """
 2 This example shows an icon
 3 in the titlebar of the window.
 4 
 5 """
 6 
 7 import sys
 8 from PyQt5.QtWidgets import QApplication, QWidget
 9 from PyQt5.QtGui import QIcon
10 
11 
12 class Example(QWidget):  # The Example class inherits from the QWidget class
13 
14     def __init__(self):
15         super().__init__()  # The super() method returns the parent object of the Example class
16 
17         self.initUI()
18 
19     def initUI(self):
20 
21         # locates the window on the screen and sets it size
22         self.setGeometry(300, 300, 300, 220)
23 
24         # set the title of the window
25         self.setWindowTitle('Hello World')
26 
27         # sets the application icon
28         # The QIcon receives the path to our icon
29         self.setWindowIcon(QIcon('web.png'))
30 
31         self.show()
32 
33 
34 if __name__ == '__main__':
35 
36     app = QApplication(sys.argv)
37     ex = Example()
38     sys.exit(app.exec_())

 

 

问题:如何将标题居中?

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