当前位置:网站首页>PyQt5快速开发与实战 6.1 好软件的三个维度 && 6.2 PyQt5中的布局管理 && 6.3 PyQt5的绝对位置布局
PyQt5快速开发与实战 6.1 好软件的三个维度 && 6.2 PyQt5中的布局管理 && 6.3 PyQt5的绝对位置布局
2022-07-29 09:25:00 【Ding Jiaxiong】
PyQt5快速开发与实战
6. 第6章 PyQt5 布局管理
6.1 好软件的三个维度
能用
这是最基本也是最重要的衡量标准,主要用来衡量产品需求是否合理,方向是否正确。
易用
主要看软件的布局管理架构是否合理,能否快速找到想要的东西,整个交互流程是否清晰,用户在完成某项任务的过程中是否出现卡顿。
好用
一个友好、人性化的软件界面,会使用户对所使用的软件充满好感。
三个维度的重要程度:好用 > 易用 > 能用
6.2 PyQt5中的布局管理
布局管理:绝对位置和布局类。
布局方式:水平布局、垂直布局、网格布局、表单布局。
布局方法:addLayout() 【在布局中插入子布局】、 addWidget()【在布局中插入控件】
四种布局方式对应四个布局类:
- 水平布局类(QHBoxLayout),可以把所添加的控件在水平方向上依次排列。
- 垂直布局类(QVBoxLayout),可以把所添加的控件在垂直方向上依次排列。
- 网格布局类(QGridLayout),可以把所添加的控件以网格的形式排列。
- 表单布局类(QFormLayout),可以把所添加的控件以两列的形式排列。
6.3 PyQt5的绝对位置布局
绝对位置布局(Absolute Positioning Layout)主要是通过在窗口程序中指定每一个控件的显示坐标和大小来实现的。最开始的坐标在左上角(0,0)的位置,以(0,0)为原点定位窗口某一点的具体位置。显示坐标的表示方法是(x,y),x是横坐标,从左到右变化;y是纵坐标,从上到下变化。在绝对位置布局中,窗口中的控件采用绝对位置进行布局。
import sys
from PyQt5.QtWidgets import QWidget , QLabel , QApplication
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
lb1 = QLabel("欢迎你",self)
lb1.move(15,10)
lb1 = QLabel("丁家雄", self)
lb1.move(35, 40)
lb1 = QLabel("!", self)
lb1.move(55, 70)
self.setGeometry(300 , 300 , 320 , 120)
self.setWindowTitle("绝对位置布局案例")
if __name__ == '__main__':
from pyqt5_plugins.examples.exampleqmlitem import QtCore
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
app = QApplication(sys.argv)
myWin = Example()
myWin.show()
sys.exit(app.exec_())
绝对位置布局的优点:
- 可以直接定位每个控件的位置。
绝对位置布局的缺点:
- 如果改变一个窗口的大小,窗口中控件的大小和位置不会随之改变。
- 所生成的窗口在不同的操作系统下看起来可能不一样。
- 在程序中改变字体时可能会破坏布局。
- 如果修改布局,比如新增一个控件,就必须全部重新布局,既烦琐又费时。
边栏推荐
- 用户身份标识与账号体系实践
- 基于ArkUI eTS开发的坚果新闻(NutNews)
- Safety is no longer the only selling point. Test drive "slash youth" Volvo C40
- Rocky基础之编译安装apache
- Acwing game 59 [End]
- Redis command [gradually improved]
- Asp graduation project - based on C # +asp Net+sqlserver laboratory reservation system design and Implementation (graduation thesis + program source code) - Laboratory Reservation System
- Quick sorting (quick sorting) (implemented in C language)
- 数据表示与计算(进制)
- File upload and expansion
猜你喜欢
【机器学习】逻辑回归代码练习
Handwritten character recognition
Notes on network principles (five layer network)
Database system design: partition
STM32 application development practice tutorial: design and implementation of controllable LED water lamp
Discussion on the integration of storage and calculation and the calculation in storage
AxureRP原型设计 快速开始
First order traversal / second order traversal determines the approximate shape of the tree
Excellent package volume optimization tutorial
Using logistic regression and neural network to deal with complex binary classification problems
随机推荐
23考研人撑住!考研第一波弃考高峰期已经到来!
Webassembly 2022 questionnaire results are fresh
MySQL error summary
Configuration file settings for remote connection to Windows version server redis
QMainWindow 详解
dataframe. to_ Sql() inserts too many errors at one time
The use and Simulation of string function, character function and memory function
(视频+图文)机器学习入门系列-第1章 引言
基于ArkUI eTS开发的坚果新闻(NutNews)
Redis series 3: highly available master-slave architecture
Tesseract图文识别--简单
附录2-一些简单的练习
Flowable 基础篇2
Safety is no longer the only selling point. Test drive "slash youth" Volvo C40
Jetpack Glance? The spring of widgets is coming
Leetcode:132. split palindrome string II
The gold content of PMP certificate has been increased again and included in the scope of Beijing work residence permit
常用的DOS命令[逐渐完善]
Unity 引导系统.点击目标物体后提示文字变色进入下一步
mysql怎么换成中文