1 import sys
2 from PyQt5.QtWidgets import QWidget,QLabel,QApplication
3 #demo_8: 绝对定位
4
5 class Example(QWidget):
6 def __init__(self):
7 super().__init__()
8 self.initUI()
9
10 def initUI(self):
11 label_1=QLabel('Zetcode',self)#文本内容,第二个参数标示这个文本放在那个窗体中,self即当前窗体
12 label_1.move(26,40)
13
14 lbl2 = QLabel('tutorials', self)
15 lbl2.move(35, 40)
16
17 lbl3 = QLabel('for programmers', self)
18 lbl3.move(55, 70)
19
20 self.setGeometry(200,200,200,200)
21 self.setWindowTitle('绝对定位')
22 self.show()
23 if __name__=='__main__':
24 app=QApplication(sys.argv)
25 e=Example()
26 sys.exit(app.exec())