PyQt5笔记(05) -- 绝对位置

来源:互联网 发布:华诚律师事务所 知乎 编辑:程序博客网 时间:2024/06/10 03:32

本节主要介绍PyQt5里绝对位置的使用

import sysfrom PyQt5.QtWidgets import QApplication, QWidget, QLabel, QMainWindowfrom PyQt5.QtGui import QIconclass App(QWidget):    def __init__(self):        super().__init__()        self.title = 'PyQt absolute positioning'        self.left = 30        self.top = 30        self.width = 440        self.height = 280        self.initUI()    def initUI(self):        self.setWindowTitle(self.title)        self.setGeometry(self.left, self.top, self.width, self.height)        label = QLabel('Python', self)        label.move(50, 50)        label2 = QLabel('PyQt5', self)        label2.move(100, 100)        label3 = QLabel('Examples', self)        label3.move(150,150)        label4 = QLabel('pytonspot.com', self)        label4.move(200,200)        self.show()if __name__ == '__main__':    app = QApplication(sys.argv)    ex = App()    sys.exit(app.exec_())

效果如下:
绝对位置