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())

