当前位置:网站首页>Pyqt5 rapid development and practice 6.1 three dimensions of good software & 6.2 layout management in pyqt5 & 6.3 absolute location layout of pyqt5
Pyqt5 rapid development and practice 6.1 three dimensions of good software & 6.2 layout management in pyqt5 & 6.3 absolute location layout of pyqt5
2022-07-29 09:26:00 【Ding Jiaxiong】
PyQt5 Rapid development and actual combat
List of articles
6. The first 6 Chapter PyQt5 Layout management
6.1 The three dimensions of good software
It works
This is the most basic and important measurement , It is mainly used to measure whether the product demand is reasonable , Is the right direction .
Easy to use
It mainly depends on whether the layout management architecture of the software is reasonable , Can you find what you want quickly , Whether the whole interaction process is clear , Whether the user gets stuck in the process of completing a task .
To use
A friendly 、 Humanized software interface , It will make users feel good about the software they use .
The importance of the three dimensions : To use > Easy to use > It works
6.2 PyQt5 Layout management in
Layout management : Absolute position and layout class .
layout : Horizontal layout 、 Vertical layout 、 Grid layout 、 Form layout .
Layout method :addLayout() 【 Insert sub layout in layout 】、 addWidget()【 Insert control in layout 】
The four layout methods correspond to four layout classes :
- Horizontal layout class (QHBoxLayout), You can arrange the added controls in the horizontal direction .
- Vertical layout class (QVBoxLayout), You can arrange the added controls in the vertical direction .
- Grid layout class (QGridLayout), You can arrange the added controls in the form of a grid .
- Form layout class (QFormLayout), You can arrange the added controls in two columns .
6.3 PyQt5 Absolute position layout of
Absolute position layout (Absolute Positioning Layout) It is mainly realized by specifying the display coordinates and size of each control in the window program . The initial coordinates are in the upper left corner (0,0) The location of , With (0,0) Locate the specific position of a point in the window for the origin . The representation of display coordinates is (x,y),x Abscissa , Change from left to right ;y Ordinate , Change from top to bottom . In absolute position layout , The controls in the window are laid out in absolute positions .
import sys
from PyQt5.QtWidgets import QWidget , QLabel , QApplication
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
lb1 = QLabel(" Welcome ",self)
lb1.move(15,10)
lb1 = QLabel(" Ding Jiaxiong ", self)
lb1.move(35, 40)
lb1 = QLabel("!", self)
lb1.move(55, 70)
self.setGeometry(300 , 300 , 320 , 120)
self.setWindowTitle(" Absolute position layout case ")
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_())

Advantages of absolute location layout :
- You can directly locate the location of each control .
Disadvantages of absolute position layout :
- If you change the size of a window , The size and position of controls in the window will not change .
- The generated windows may look different under different operating systems .
- Changing the font in the program may damage the layout .
- If you modify the layout , For example, add a new control , It must be completely rearranged , Cumbersome and time-consuming .
边栏推荐
- Using logistic regression and neural network to deal with complex binary classification problems
- [Yunzhu co creation] [hcsd live broadcast] teach the interview tips of big companies in person
- Retinal Vessel Segmentation via a Semantics and Multi-Scale Aggregation Network
- "Defects" of prototype chain inheritance and constructor inheritance
- Floweable foundation Chapter 1
- Acwing game 59 [End]
- 高智伟:数据管理赋能交通行业数字化转型
- Reptile practice (10): send daily news
- (Video + graphics) introduction to machine learning series - Chapter 1 Introduction
- Handwritten character recognition
猜你喜欢
随机推荐
浅谈契约测试
Parameter initialization
[unity entry program] collection of common learning websites
How to export the old and new file names and locations to excel after file renaming
[centralized training] hcip cloud computing resource exchange post
STM32 application development practice tutorial: getting to know STM32 for the first time
Excellent package volume optimization tutorial
On the charm of code language
How to contribute to openharmony
机器学习之分类模型评估指标及sklearn代码实现
如何为OpenHarmony做贡献
Webassembly 2022 questionnaire results are fresh
A structured random inactivation UNET for retinal vascular segmentation
Outlook tutorial, how to create an electronic signature in outlook?
36. JS animation
What should I pay attention to now? Excuse me, is it safe to open a stock account by mobile phone?
Custom configuration
View port occupancy
高智伟:数据管理赋能交通行业数字化转型
【机器学习】朴素贝叶斯代码练习









![[machine learning] naive Bayesian code practice](/img/42/38e8cfa8ebfbb0e14c2e26ffc6c793.png)