当前位置:网站首页>Understanding and application of Qt5 layout in creation
Understanding and application of Qt5 layout in creation
2022-07-01 01:32:00 【Teacher Detian】
The core of programming
In order to skillfully learn and understand the important role of the program , We need to constantly design different types of works , So as to realize the skills and methods of programming .
from PyQt5.Qt import *
import sys
app = QApplication([])
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle('DT System ')
self.resize(1248,450)
qr = self.frameGeometry()
cp = QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
# In vertical layout Add horizontal layout , first floor
layout = QVBoxLayout()
top_lout = QHBoxLayout() # Top level horizontal layout
btn_start = QPushButton()
btn_start.setText(' Start ')
top_lout.addWidget(btn_start) # Buttons are added to the layout
btn_stop = QPushButton()
btn_stop.setText(' stop it ')
top_lout.addWidget(btn_stop)
top_lout.addStretch() # Add a spring on the right side to make the two buttons close to the left
layout.addLayout(top_lout) # The top-level layout is added to the general layout
layout.addStretch() # Add a spring to the general layout , Before making 2 A horizontal layout faces up .
mid_lout = QHBoxLayout() # Middle horizontal layout
le = QLineEdit()
mid_lout.addWidget(le) # Add a text input box to the middle horizontal layout
btn_stop = QPushButton()
btn_stop.setText(' add to ')
mid_lout.addWidget(btn_stop) # Add buttons to the middle horizontal layout
layout.addLayout(mid_lout) # The middle horizontal layout is added to the general layout
# Create table layout
table_layout = QHBoxLayout()
tw = QTableWidget(0, 8) # add to 2 That's ok , total 8 Column
table_header = [
{"field":"asin","text":"ASIN",'width':120},
{"field":"title","text":" title ",'width':150},
{"field":"url","text":"URL",'width':400},
{"field":"price","text":" Floor price ",'width':100},
{"field":"success","text":" Number of successes ",'width':100},
{"field":"error","text":"503 frequency ",'width':100},
{"field":"status","text":" state ",'width':100},
{"field":"frequency","text":" frequency (N second / Time )",'width':100}]
for idx,info in enumerate(table_header):
item = QTableWidgetItem()
item.setText(info['text']) # Get the dictionary through a loop key='Text' Value
tw.setHorizontalHeaderItem(idx, item) #idx from 0-7, matching 1~8 Column ,item Is the corresponding text As column name
tw.setColumnWidth(idx, 112)
item = QTableWidgetItem()
item.setText(' website ')
tw.setHorizontalHeaderItem(1, item)
tw.setColumnWidth(1, 400)
table_layout.addWidget(tw)
layout.addLayout(table_layout)
layout.addStretch() # Add springs to the general layout
bottom_lout = QHBoxLayout() # A horizontal area at the bottom
bottom_lout.addStretch() # Squeeze command added on the left
lab = QLabel(' A literary creation : Teacher Detian ') # Align to the right under the squash command above
bottom_lout.addWidget(lab) # The label is added to the bottom horizontal area
layout.addLayout(bottom_lout)
self.setLayout(layout) # Layout and window binding , Display... Through the window
win = Window()
win.show()
sys.exit(app.exec_())

边栏推荐
猜你喜欢

Dx-11q signal relay

基础知识之二——STA相关的基本定义

Basic knowledge 3 - standard unit library

Call the classic architecture and build the model based on the classic

3dsmax插件开发遍历节点对象和Object获取及INode变换矩阵说明

微研所,微生物检验中常用的生化反应

gin_ gorm

flutter报错 -- The argument type ‘Function‘ can‘t be assigned to the parameter type ‘void Function()?‘

Q play soft large toast to bring more comfortable sleep

Dls-42/6-4 dc110v double position relay
随机推荐
Note d'étude du DC: zéro dans le chapitre officiel - - Aperçu et introduction du processus de base
JS to convert numbers into Chinese characters for output
二季度最后一天
dc_labs--lab1的学习与总结
Openmv and k210 of the f question of the 2021 video game call the openmv API for line patrol, which is completely open source.
Xjy-220/43ac220v static signal relay
Use of typora
User defined annotation implementation verification
Use strictmode strictmode principle (1)
About the general input operation mode of unity
Sun Yuchen told Swiss media Bilan that the bear market will not last long
ASCII、Unicode、GBK、UTF-8之间的关系
视频教程 | 长安链推出系列视频教程合集(入门)
Call the classic architecture and build the model based on the classic
[问题已处理]-nvidia-smi命令获取不到自身容器的GPU进程和外部的GPU进程号
1175. Prime Arrangements
gin_ gorm
What will Web3 bring in the future?
6月第4周榜单丨飞瓜数据UP主成长排行榜(哔哩哔哩平台)发布!
sort自定义函数