zoukankan      html  css  js  c++  java
  • 布局管理——复习示例

    效果如下:

    示例代码:

    #!/usr/bin/python3
    # -*- coding: utf-8 -*-
    
    """
    ZetCode PyQt5 tutorial
    
    In this example, we create a bit
    more complicated window layout using
    the QGridLayout manager.
    
    author: Jan Bodnar
    website: zetcode.com
    last edited: January 2015
    """
    
    import sys
    from PyQt5.QtWidgets import (QWidget, QLabel, QLineEdit,
        QTextEdit, QGridLayout, QApplication)
    
    
    class Example(QWidget):
    
        def __init__(self):
            super().__init__()
    
            self.initUI()
    
        def initUI(self):
    
            title = QLabel('Title')
            author = QLabel('Author')
            review = QLabel('Review')
    
            titleEdit = QLineEdit()
            authorEdit = QLineEdit()
            reviewEdit = 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(review, 3, 0)
            grid.addWidget(reviewEdit, 3, 1, 5, 1)
    
            self.setLayout(grid)
    
            self.setGeometry(300, 300, 350, 300)
            self.setWindowTitle('Review')
            self.show()
    
    
    if __name__ == '__main__':
    
        app = QApplication(sys.argv)
        ex = Example()
        sys.exit(app.exec_())
  • 相关阅读:
    Mac普通用户修改了/etc/sudoers文件的解决办法
    python对缓存(memcached,redis)的操作
    线程、进程、协程和队列
    python作用域和多继承
    sokect编程进阶
    socket编程基础
    python面相对象进阶
    python异常处理
    configparser模块
    subprocess模块
  • 原文地址:https://www.cnblogs.com/fuqia/p/8733511.html
Copyright © 2011-2022 走看看