python - 从 DataFrame 填充 wxPython Grid
问题描述
我正在构建一个 GUI 来查看和更新 mySQL 中的表。我正在获取结果,将它们加载到 Pandas DataFrame 中,然后将它们写到网格中。
从 mySQL 到 DataFrame,几乎是即时的。问题是循环每个值并将它们写入网格需要一些时间。我正在尝试找到一种更快的方法来填充网格。我已经研究过使用 GridTableBase 类,但我并没有真正理解它,因为我对 Python 不是很有经验。
要加载 DataFrame,我正在使用:
db_con = MySQLdb.connect(user=user_id,password=pw,database=db_name,host=host_id,charset='utf8')
cursor = db_con.cursor()
填充 wxPython 网格:(由于某种原因,这会在同一张表上引发错误)
#Populate Grid
for i in range(len(self.df_data.index)):
for j in range(len(self.df_data.columns)):
self.data_grid.SetCellValue(i,j,self.df_data.iat[i,j])
UPDATE: I have used the GridTableBase. The result is not much faster
解决方案
推荐阅读
- angular - 突出显示新添加的垫卡
- c# - How can I troubleshoot: A connection was successfully established with the server, but then an error occurred during the login process
- onclick - 检查元素是否是 Dart 中另一个元素的子元素
- python - How to convert dictionary into a specific format
- javascript - Ember.js 项目与 IE 10 的兼容性
- qt - Qt/Qml 3D 如何从顶点数组渲染网格
- javascript - 厌倦了 Medium.com 优质内容。我可以隐藏针对具有特定类的元素的父元素的高级帖子吗?
- node.js - Mongoose - 如何根据条件填充子文档
- reactjs - 如何在反应日期中自定义标题月份和年份
- python - Python/Pandas 在阶跃函数中为数据点使用不同的颜色