python 从 wx.ListCtrl 打印内容
时,我创建了一个列表,
self.statusListCtrl = wx.ListCtrl(self.panelUpper, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
当我使用“当我的过程全部完成时”将数据添加到此列表
self.statusListCtrl.Append([datetime.datetime.now(),action,result])
我有一个很好的列表,显示已尝试的内容、该尝试的结果和日期时间戳。现在我想做的是将其输出到文本文件。我的问题是我无法正确从 listctrl 获取数据。
这就是我尝试迭代列表的方式。
fileName = 'd:\ssplogs\sspInstaller.log'
FILE = open(fileName,"w")
for itemIdx in range(0,self.statusListCtrl.GetItemCount()):
line = str(self.statusListCtrl.GetItemText(itemIdx) + "\n")
print "line" , line
writeLine = line
FILE.write(writeLine)
FILE.close()
我得到的输出只是我的日期时间戳,这是我列表的第一列。我如何得到这个,以便我看到类似的东西
datetime, action, result
I have a list created as
self.statusListCtrl = wx.ListCtrl(self.panelUpper, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
I add data to this list using
self.statusListCtrl.Append([datetime.datetime.now(),action,result])
When my process is all done I have a nice list showing things that were tried, the result of that attempt and a datetime stamp. Now what I want to do is output that to a text file. my problem is that I cant get the data from my listctrl correctly.
This is how I am trying to iterate through the list.
fileName = 'd:\ssplogs\sspInstaller.log'
FILE = open(fileName,"w")
for itemIdx in range(0,self.statusListCtrl.GetItemCount()):
line = str(self.statusListCtrl.GetItemText(itemIdx) + "\n")
print "line" , line
writeLine = line
FILE.write(writeLine)
FILE.close()
The output I am getting though is only my datetime stamp, which is the first column of my list. How do I get this so I see something like
datetime, action, result
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用它来获取行 x 列数据:
工作示例:
Use this to get Row x Column data:
Working example: