import sys
from PyQt5.QtWidgets import (QApplication, QWidget, QHBoxLayout,
QFrame, QSplitter)
from PyQt5.QtCore import Qt
class Example(QWidget):
def __init__(self):
super().__init__()
hbox = QHBoxLayout(self)
topleft = QFrame(self)
topleft.setFrameShape(QFrame.StyledPanel) # 设置边框
topright = QFrame(self)
topright.setFrameShape(QFrame.StyledPanel) # 设置边框
splitter1 = QSplitter(Qt.Horizontal)
splitter1.addWidget(topleft)
splitter1.setSizes([100, ]) # 设置分隔条位置
splitter1.addWidget(topright)
hbox.addWidget(splitter1)
self.setLayout(hbox)
self.setGeometry(600, 600, 600, 600)
self.setWindowTitle('窗口分隔')
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())