from PyQt5.Qt import *
class Window(QTabWidget):
def __init__(self,parent=None):
super().__init__(parent)
self.resize(500,500)
self.parent=parent
self.tab1=QWidget()
self.tab2=QWidget()
self.tab3=QWidget()
self.tab4=QWidget()
self.addTab(self.tab1,'Tab1')
self.addTab(self.tab2,'Tab2')
self.addTab(self.tab3,'Tab3')
self.addTab(self.tab4,'Tab4')
self.tab1_ui()
self.tab2_ui()
self.tab3_ui()
self.tab4_ui()
def tab1_ui(self):
layout=QFormLayout()
layout.addRow("Name",QLineEdit())
layout.addRow("adress",QLineEdit())
layout.setSpacing(40)
self.setTabText(0,"联系方式")
self.tab1.setLayout(layout)
def tab2_ui(self):
layout=QFormLayout()
sex=QHBoxLayout()
sex.addWidget(QRadioButton("男"))
sex.addWidget(QRadioButton("女"))
sex.setSpacing(50)
layout.addRow(QLabel("性别"),sex)
layout.addRow(QLabel("生日"),QLineEdit())
self.setTabText(1,"个人详细信息")
self.tab2.setLayout(layout)
def tab3_ui(self):
layout=QHBoxLayout()
layout.addWidget(QLabel("科目"))
layout.addWidget(QCheckBox("物理"))
layout.addWidget(QCheckBox("数学"))
layout.addWidget(QCheckBox("英语"))
self.setTabText(2,"教育程度")
self.tab3.setLayout(layout)
def tab4_ui(self):
layout=QVBoxLayout()
clock_widget=Clock()
layout.addWidget(clock_widget)
self.tab4.setLayout(layout)
self.setTabText(3,"时钟")
pyqt5之布局
于 2022-10-09 14:16:21 首次发布