zoukankan      html  css  js  c++  java
  • pyqt 控件随窗口改变而改变

    # _*_coding:utf-8_*_
    # author:leo
    # date:
    # email:alplf123@163.com
    
    from PyQt5.QtWidgets import QApplication, QMainWindow, QTextEdit, QWidget, QVBoxLayout, QFrame
    from PyQt5.Qt import QSize
    import sys
    
    class Example(QMainWindow):
    
        def __init__(self):
            super(Example, self).__init__()
    
            self._initUI()
        def _initUI(self):
            #控件随窗口改变而改变
            # 可以通过继承 QMainWindow 来实现
            self.resize(400, 400)
            #建立顶层控件
            self.centeralwidget = QWidget()
            self.vbox = QVBoxLayout(self.centeralwidget)
            edit = QTextEdit()
            self.vbox.addWidget(edit)
            #通过设置中心控件,将子控件填充布局
            #如果有多个控件最好在加一层widget这样最好布局,控制
            self.setCentralWidget(self.centeralwidget)
            self.show()
    
    
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        ex = Example()
        sys.exit(app.exec_())
  • 相关阅读:
    安装redis
    memcached复制-repcached
    memcached一致性哈希及php客户端实现
    安装php
    安装mysql
    安装apache
    putty配色方案
    virtualbox下centos实现主宿互访
    安装memcached
    linux网络、性能相关命令
  • 原文地址:https://www.cnblogs.com/alplf123/p/8894138.html
Copyright © 2011-2022 走看看