当前位置:网站首页>PyQt5可视化开发
PyQt5可视化开发
2022-06-28 12:04:00 【HanWang~】
pyuic
将.ui文件转为.py文件
python -m PyQt5.uic.pyuic demo.ui -o demo.py
数据库
使用sqllite数据库进行增加(Create)、检索(Retrieve)、更新(Update)和删除(Delete)操作。
对于数据库内的数据可视化,使用SQLite Expert Personal,下载地址。
数据库建表报错
报错信息: AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY
需要大写奥‘INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL’
sql = 'CREATE TABLE if not exists stuinfo (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name String(10), grade String(20), pwd String(20), code String(20))'
vertical Layout清空内容
清空layout中所有对象
参考
结合前面的注意事项,清空一个layout中所有对象控件的代码如下:
item_list = list(range(self._ui.myLayout.count()))
item_list.reverse()# 倒序删除,避免影响布局顺序
for i in item_list:
item = self._ui.myLayout.itemAt(i)
self._ui.myLayout.removeItem(item)
if item.widget():
item.widget().deleteLater()
自己用到的代码:
清空一个
if self.verticalLayout.count() !=0 :
item = self.verticalLayout.itemAt(0)
item.widget().deleteLater()
关键代码总结:
item_list.reverse()是为了反转序列的顺序,从而实现倒序删除layout中元素的效果。
myLayout.removeItem(item)是为了删除layout中的QLayoutItem对象
item.widget().deleteLater()是为了删除item中的widget对象
pyqtgraph画图
import pyqtgraph as pg
plt = pg.PlotWidget(title='成绩统计图')
plt.setBackground('w')
plt.setLabel('left', '成绩')
plt.setLabel('bottom', 'time')
plt.addLegend()
x = np.array(range(4))
xticks = [list(zip(range(4), ('a', 'b', 'c', 'd')))]
xaxis = plt.getAxis('bottom')
xaxis.setTicks(xticks)
# x_label = np.array(
# ['128iodp_8jobs_60K_1pan', '128iodp_16jobs_1M_1pan', '128iodp_8jobs_60K_4pan', '128iodp_16jobs_1M_4pan'])
temp_map = {
}
temp_map['xTick'] = [(0, '2021-01-01'),(1, '2021-02-0'),(2, '2021-03-01'),(3, '2021-04-01'),(4, '2021-05-01'),(5, '2021-06-01'),(6, '2021-07-01')]
bw1 = np.array([235, 270, 753, 892])
plt.plot(x,bw1, pen=(255, 0, 0), name='成绩')
# plt.plot(np.random.normal(size=110) + 5, pen=(0, 255, 0), name='Green curve')
# plt.plot(np.random.normal(size=120) + 10, pen=(0, 0, 255), name='Blue curve')
# 图形插入pyqtlayout:
# plt.plot_data(temp_map)
# (x, labels=, rotation=0, ha='center')
self.verticalLayout.addWidget(plt)
边栏推荐
- Url追加参数方法,考虑#、?、$的情况
- Open3d manual clipping point cloud
- Build your own website (18)
- Unity加载设置:Application.backgroundLoadingPriority
- Share the easy-to-use fastadmin open source system - practical part
- 【Unity编辑器扩展基础】、GUILayout
- JNI函数的2种书写方式
- [Beijing University of Aeronautics and Astronautics] information sharing for the first and second examinations of postgraduate entrance examination
- 【C语言】如何很好的实现复数类型
- Intranet penetration in the working group environment: some basic methods
猜你喜欢

【C语言】结构体嵌套二级指针的使用
![[C language] about scanf() and scanf_ Some problems of s()](/img/d1/e3d0b845e699c8c1fe3eb9f3b250e1.png)
[C language] about scanf() and scanf_ Some problems of s()

Many benefits of SEO optimization are directly related to traffic

Fruit FL studio/cubase/studio one music host software comparison
![[C language] use of nested secondary pointer of structure](/img/59/8b61805431e152995c250f6dd08e29.png)
[C language] use of nested secondary pointer of structure

SEO优化的许多好处是与流量有直接关系
![[vi/vim] basic usage and command summary](/img/bc/0be3ae3f122c3c21b480e0678095a1.png)
[vi/vim] basic usage and command summary

What is data compliance? How to achieve data compliance?

【C语言】关于scanf()与scanf_s()的一些问题

Ali three sides: what is the difference between using on or where in the left join associated table and the condition
随机推荐
双缓冲绘图
fatal: unsafe repository (‘/home/anji/gopath/src/gateway‘ is owned by someone else)
【C语言】文件读写函数使用
[C language] use of nested secondary pointer of structure
Chapter 2 do you remember the point, line and surface (2)
【vi/vim】基本使用及命令汇总
Random forest and poetry maker trained by AMR
SEO优化的许多好处是与流量有直接关系
Difference (one dimension)
Share the easy-to-use fastadmin open source system - practical part
【C语言】结构体嵌套二级指针的使用
6. calculation index
KDD 2022 | graph neural network generalization framework under the paradigm of "pre training, prompting and fine tuning"
【Unity编辑器扩展实践】、查找所有引用该图片的预制体
AcWing 609. Salary (implemented in C language)
[C language] use of file read / write function
IO stream of file and Base64
Redis hash hash type string (5)
纯纯大怨种!那些年被劝退的考研专业
Remoteviews layout and type restriction source code analysis