其他分享
首页 > 其他分享> > pyqt5窗体分隔

pyqt5窗体分隔

作者:互联网

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

标签:__,splitter1,分隔,600,self,topright,pyqt5,窗体,QFrame
来源: https://www.cnblogs.com/kukai/p/10766412.html