当前位置:网站首页>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_())

绝对位置布局的优点:
- 可以直接定位每个控件的位置。
绝对位置布局的缺点:
- 如果改变一个窗口的大小,窗口中控件的大小和位置不会随之改变。
- 所生成的窗口在不同的操作系统下看起来可能不一样。
- 在程序中改变字体时可能会破坏布局。
- 如果修改布局,比如新增一个控件,就必须全部重新布局,既烦琐又费时。
边栏推荐
- 数据表示与计算(进制)
- 【BERT-多标签文本分类实战】之一——实战项目总览
- 数仓项目踩坑记录与解决方法总结
- 使用cpolar发布树莓派网页(cpolar隧道的完善)
- Reptile practice (10): send daily news
- [Yunzhu co creation] [hcsd live broadcast] teach the interview tips of big companies in person
- Trie树(字典树)讲解
- [centralized training] hcip cloud computing resource exchange post
- mysql将部分表名统一转换为大写
- Commonly used DOS commands [gradually improved]
猜你喜欢

Introduction to translation professional qualification (level) examination

dataframe.to_sql() 一次性插入过多报错

Flowable UI制作流程图

NFA determination and DFA minimization based on C language

How to query express logistics and filter out no information doc No. to delete or copy

当 update 修改数据与原数据相同时会被更新吗?

STM32 application development practice tutorial: getting to know STM32 for the first time

Cloud native management practice: business led Devops continuous delivery system

Evaluation index of machine learning classification model and implementation of sklearn code

怎样查询快递物流筛选出无信息单号删除或者复制
随机推荐
[Bert multi label text classification practice] I - overview of practical projects
Floweable foundation Chapter 1
Evaluation index of machine learning classification model and implementation of sklearn code
VS2015采用loadlibrary方式调用dll库
【云驻共创】【HCSD大咖直播】亲授大厂面试秘诀
Four types of technical solutions shared by distributed sessions, and their advantages and disadvantages
Summary of research on endogenous information security technology of industrial measurement and control equipment
201803-3 Full Score solution of CCF URL mapping
Will the modified data be updated when it is the same as the original data?
网络原理笔记(五层网络)
浅谈契约测试
I don't know how lucky the boy who randomly typed logs is. There must be a lot of overtime
Discussion on the integration of storage and calculation and the calculation in storage
Quick sorting (quick sorting) (implemented in C language)
File upload and expansion
Could not receive a message from the daemon
Quaternion and its simple application in unity
Implementation of DFA string recognition based on C language simulation
数仓项目踩坑记录与解决方法总结
On the charm of code language