import sys from PyQt5.QtWidgets import QWidget, QLabel, QApplication, QLineEdit, QTextEdit, QGridLayout class Example(QWidget): def __init__(self): super().__init__() self.initUI() #---------------------------------------------------------- def initUI(self): title = QLabel('主题') author = QLabel('用户') content = QLabel('内容') titleEdit = QLineEdit() authorEdit = QLineEdit() contentEdit = QTextEdit() grid = QGridLayout() grid.setSpacing(10) # 控件之间的间距 grid.addWidget(title, 1, 0) grid.addWidget(titleEdit, 1, 1) grid.addWidget(author, 2, 0) grid.addWidget(authorEdit, 2, 1) grid.addWidget(content, 3, 0) grid.addWidget(contentEdit, 3, 1, 10, 1) #10为控件所占行数, 1为列数 self.setLayout(grid) #------------------------------------------------------------ self.setGeometry(300, 300, 300, 150) self.setWindowTitle('review') self.show() #------------------------------------------------------------- if __name__ == '__main__': app = QApplication(sys.argv) ex = Example() sys.exit((app.exec_()))
转载请注明作者与出处:http://blog.csdn.net/u013511642 王小涛_同學
时间: 2024-10-23 04:45:39