【发布时间】:2017-08-23 09:22:43
【问题描述】:
我正在从一个巨大的日志中提取数据,然后更新 wxPython 网格中的条目。使用我的代码,只有在操作完成后才能看到窗口,完成操作需要 5 分钟。有没有办法从 time = 0 本身更新和查看网格上的数据。 我试过了:
import wx
import wx.grid as gridlib
class MyForm(wx.Frame):
def __init__(self):
##
# constructor to create the basic frame
wx.Frame.__init__(self, None, wx.ID_ANY, "Tool")
# Add a panel so it looks the correct on all platforms
panel = wx.Panel(self, wx.ID_ANY)
self.grid = gridlib.Grid(panel)
rows = 4
column = 600000
self.grid.CreateGrid(column, rows)
self.count = 0
# change a couple column labels
self.grid.SetColLabelValue(0, "Timestamp")
self.grid.SetColLabelValue(1, "CMD")
self.grid.SetColLabelValue(2, "Address")
self.grid.SetColLabelValue(3, "Data")
# Few More operations to calculate CMD,Timestamp field
for i in range(10**5):
self.count += 1
self.grid.SetCellValue(self.count,1,'CMD4')
self.grid.SetCellValue(self.count,0,str(self.count))
self.grid.SetCellValue(self.count, 2, "Extracted Address")
self.grid.SetCellValue(self.count, 3, "Extracted Data")
# change the row labels
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.grid, 1, wx.EXPAND, 5)
panel.SetSizer(sizer)
if __name__ == "__main__":
app = wx.App()
frame = MyForm()
frame.Show()
app.MainLoop()
【问题讨论】:
标签: python python-2.7 user-interface wxpython