从 DataFrame 填充 wxPython 网格

问题描述

我正在构建一个 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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)