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

边栏推荐
- Relationship between ASCII, Unicode, GBK, UTF-8
- 微研所,微生物检验中常用的生化反应
- TypeError: can‘t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to
- Use strictmode strictmode principle (1)
- Introduction and principle analysis of cluster and LVS
- Orb-slam2 source code learning (II) map initialization
- ASCII、Unicode、GBK、UTF-8之间的关系
- Strictmode analysis activity leakage -strictmode principle (3)
- Using recyclerreview to show banner is very simple
- MFC TCP通信服务端客户端Demo备忘vs2019
猜你喜欢

Green, green the reed. dew and frost gleam.

Typora的使用

Service grid ASM year end summary: how do end users use the service grid?

关于白盒测试,这些技巧你得游刃有余~

Koa koa combine routes sub route management

Pre training / transfer learning of models

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

Basic knowledge II - Basic definitions related to sta

Openmv and k210 of the f question of the 2021 video game call the openmv API for line patrol, which is completely open source.

zabbix如何配置告警短信?(预警短信通知设置流程)
随机推荐
编译安装oh-my-zsh
微生物检测,土壤微生物的作用有哪些?
Basic knowledge of software and hardware -- diary (1)
Microbiological health, why is food microbiological testing important
The argument type 'function' can't be assigned to the parameter type 'void function()‘
Service grid ASM year end summary: how do end users use the service grid?
System.CommandLine版CSRebot
System settings large page
Q play soft large toast to bring more comfortable sleep
Applet Custom Grid
关于白盒测试,这些技巧你得游刃有余~
Sécurité et santé microbiennes, qu'est - ce que le traitement biologique?
【Qt5-基础篇】随机数显示屏展示
dc_labs--lab1的学习与总结
"Open math input panel" in MathType editing in win11 is gray and cannot be edited
Open3d point cloud color rendering
uniapp官方组件点击item无效,解决方案
短信在企业中的应用有哪些?
Complete software development process
农产品换房?“变相”购房补贴!