datetime:2019/5/20 14:34
author:nzb
布局添加标签
import sys
from PyQt5.QtWidgets import QApplication, QDialog, QVBoxLayout, QLabel
from PyQt5 import QtGui
class UI_demo(QDialog):
"""用户界面"""
def __init__(self):
super().__init__()
self.title = 'PyQt5 Layout Managment'
self.left = 600
self.top = 200
self.width = 500
self.height = 200
self.initWindow()
def initWindow(self):
self.setWindowIcon(QtGui.QIcon('../img/home.ico'))
self.setGeometry(self.left, self.top, self.width, self.height)
self.setWindowTitle(self.title)
vbox = QVBoxLayout()
label = QLabel('This is PyQt5 Label.')
vbox.addWidget(label)
label2 = QLabel('This is big Label.')
label2.setFont(QtGui.QFont("Sanserif", 20))
label2.setStyleSheet("color:red")
vbox.addWidget(label2)
self.setLayout(vbox)
self.show()
if __name__ == "__main__":
app = QApplication(sys.argv)
ex = UI_demo()
sys.exit(app.exec_())