当前位置:网站首页>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)
边栏推荐
- MapReduce项目案例3——温度统计
- 【C语言】结构体嵌套二级指针的使用
- Oracle date format exception: invalid number
- Data analysis learning notes
- Interview skills for interview steps
- Web3 security serials (3) | in depth disclosure of NFT fishing process and prevention techniques
- 6.A-B
- AcWing 608. Poor (implemented in C language)
- Day32 JS note event (Part 1) September 27, 2021
- What method is required for word, PDF and txt files to realize full-text content retrieval?
猜你喜欢
Leetcode 48. 旋转图像(可以,已解决)
Convert black mask picture to color annotation file
JNI confusion of Android Application Security
Swin, three degrees! Eth open source VRT: a transformer that refreshes multi domain indicators of video restoration
Redis principle - List
Function and principle of remoteviews
【Unity编辑器扩展基础】、EditorGUILayout (三)
Django -- MySQL database reflects the mapping data model to models
2018 joint examination of nine provinces & Merging of line segment trees
Prefix and (2D)
随机推荐
零基础C语言(一)
Multi dimensional monitoring: the data base of intelligent monitoring
.NET混合开发解决方案24 WebView2对比CefSharp的超强优势
Chendanqi, Fang Fei, guquanquan and Li Bo won the prize, and the list of Sloan research award in 2022 was released
JS foundation 10
cdc同步 如果数据库表的主键发生了变化,会同步成两个数据 还是会同步更新主键呢?
Is there a threshold for opening futures accounts? How to open futures accounts safely on the Internet
【C语言】判断三角形
智联招聘基于 Nebula Graph 的推荐实践分享
Remote login sshd service
Url追加参数方法,考虑#、?、$的情况
SoapUI rookie tutorial
Contract quantification system development (construction explanation) - contract quantification system development (source code analysis and ready-made cases)
RemoteViews的作用及原理
【C语言】随机数文件对其进行三种排序方法
Android应用安全之JNI混淆
Two writing methods of JNI function
Practice and Thinking on the architecture of a set of 100000 TPS im integrated message system
AcWing 606. Average 1 (implemented in C language)
深度学习又有新坑了!悉尼大学提出全新跨模态任务,用文本指导图像进行抠图...