当前位置:网站首页>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)
边栏推荐
- 智联招聘基于 Nebula Graph 的推荐实践分享
- The development and principle of the metacosmic system
- 【C语言】随机数文件对其进行三种排序方法
- fatal: unsafe repository (‘/home/anji/gopath/src/gateway‘ is owned by someone else)
- 【C语言】判断三角形
- Using MySQL database in the express framework of node
- What method is required for word, PDF and txt files to realize full-text content retrieval?
- AGCO AI frontier promotion (2.16)
- Remoteviews layout and type restriction source code analysis
- Ali three sides: what is the difference between using on or where in the left join associated table and the condition
猜你喜欢

Software test interview classic + 1000 high-frequency real questions, and the hit rate of big companies is 80%

Convert black mask picture to color annotation file

UGUI强制刷新Layout(布局)组件

KDD 2022 | graph neural network generalization framework under the paradigm of "pre training, prompting and fine tuning"

【C语言】结构体嵌套二级指针的使用

Day32 JS note event (Part 1) September 27, 2021

RemoteViews的作用及原理

Simple understanding of ThreadLocal

【C语言】二叉树的实现及三种遍历

Redis principle - List
随机推荐
开源项目维权成功案例: spug 开源运维平台成功维权
cdc同步 如果数据库表的主键发生了变化,会同步成两个数据 还是会同步更新主键呢?
On the output representation of bidirectional LSTM in pytoch
Self use demo of basic component integration of fluent
CDC synchronization if the primary key of a database table changes, will it be synchronized into two data or will it be synchronized to update the primary key?
來吧元宇宙,果然這熱度一時半會兒過不去了
【Unity编辑器扩展基础】、EditorGUILayout (一)
Share the easy-to-use fastadmin open source system - practical part
Privilege management of vivo mobile phone
SEO优化的许多好处是与流量有直接关系
Batch will png . bmp . JPEG format pictures are converted to Jpg format picture
RemoteViews布局和类型限制源码分析
PrecomputedTextCompat用法及原理
Django -- MySQL database reflects the mapping data model to models
Two writing methods of JNI function
Redis hash hash type string (5)
Url追加参数方法,考虑#、?、$的情况
Redis 原理 - List
Leetcode 48. 旋转图像(可以,已解决)
Android应用安全之JNI混淆