PyQt5--QSplitter

2020-01-19 11:07:05 浏览数 (1)

代码语言:javascript复制
 1 # -*- coding:utf-8 -*-
 2 '''
 3 Created on Sep 20, 2018
 4 
 5 @author: SaShuangYiBing
 6 
 7 Comment: 
 8 '''
 9 import sys
10 from PyQt5.QtCore import Qt
11 from PyQt5.QtWidgets import QApplication,QWidget,QSplitter,QHBoxLayout,QFrame,QStyleFactory
12 
13 class New_test(QWidget):
14     def __init__(self):
15         super().__init__()
16         self.initUI()
17         
18     def initUI(self):
19         hbox = QHBoxLayout(self)
20         topleft = QFrame(self)
21         topleft.setFrameShape(QFrame.StyledPanel)
22         topright = QFrame(self)
23         topright.setFrameShape(QFrame.StyledPanel)
24         bottom = QFrame(self)
25         bottom.setFrameShape(QFrame.StyledPanel)
26         
27         splitter1 = QSplitter(Qt.Horizontal)
28         splitter1.addWidget(topleft)
29         splitter1.addWidget(topright)
30         
31         splitter2 = QSplitter(Qt.Vertical)
32         splitter2.addWidget(bottom)
33         splitter2.addWidget(splitter1)
34         
35         hbox.addWidget(splitter2)
36         self.setLayout(hbox)
37         
38         self.setGeometry(300,300,300,200)
39         self.setWindowTitle('QSplitter')
40         self.show()
41         
42         
43 if __name__ == '__main__':
44     app = QApplication(sys.argv)
45     ex = New_test()
46     sys.exit(app.exec_())

0 人点赞