datetime:2019/5/21 15:16
author:nzb
创建分离器
import sys
from PyQt5.QtWidgets import QWidget, QApplication, QLabel, QGroupBox, QCheckBox, \
QHBoxLayout, QPushButton, QButtonGroup, QSizeGrip, QFrame
from PyQt5.QtWidgets import QVBoxLayout, QRadioButton, QSplitter, QLineEdit
from PyQt5 import QtGui, QtCore
from PyQt5.QtCore import Qt
class UI_demo(QWidget):
"""用户界面"""
def __init__(self):
super().__init__()
self.title = 'PyQt5 Splitters'
self.left = 600
self.top = 200
self.width = 500
self.height = 500
self.iconName = '../img/home.ico'
self.initWindow()
def initWindow(self):
self.setWindowIcon(QtGui.QIcon(self.iconName))
self.setGeometry(self.left, self.top, self.width, self.height)
self.setWindowTitle(self.title)
hbox = QHBoxLayout()
left = QFrame()
left.setFrameShape(QFrame.StyledPanel)
bottom = QFrame()
bottom.setFrameShape(QFrame.StyledPanel)
splitter1 = QSplitter(Qt.Horizontal)
splitter1.setStyleSheet('background-color:red')
lineedit = QLineEdit()
lineedit.setStyleSheet('background-color:green')
splitter1.addWidget(left)
splitter1.addWidget(lineedit)
splitter1.setSizes([200, 200])
splitter2 = QSplitter(Qt.Vertical)
splitter2.addWidget(splitter1)
splitter2.addWidget(bottom)
splitter2.setStyleSheet('background-color:blue')
hbox.addWidget(splitter2)
self.setLayout(hbox)
self.show()
if __name__ == "__main__":
app = QApplication(sys.argv)
ex = UI_demo()
sys.exit(app.exec_())