使用 ObjectListView 将项目添加到对象
阅读此处的一些内容后,我决定使用 ObjectListView 重写一个小项目。我的问题是,当我尝试执行 self.ListObject.AddObject(object) 将项目添加到列表中时,它失败了,我不确定为什么。
这是我让用户选择目标目录的代码。在选择过程结束时,应该使用时间戳和所采取的操作来更新 ActionsOlv 的 ObjectListView。打印语句仅用于调试。
def onBrowseDest(self, event):
print "OnBrowseDest"
dest = selectFolder("Select the Destination Directory")
print dest
self.txDest.SetValue(dest)
self.anEvent = [Action(datetime.datetime.now(),dest,"Set as Destination dir")]
self.ActionsOlv.AddObject(self.anEvent)
发生的情况是,我看到列表中正在创建行,但该行没有任何内容。如果我用 SetObjects 替换 AddObject 方法
self.ActionsOlv.SetObjects(self.anEvent)
,它将更新显示,但每个换行符都会覆盖列表而不是添加到列表中。
After reading some items here I have decided to rewrite a little project using ObjectListView. My problem is that when I try to do self.ListObject.AddObject(object) to add an item to my list it fails, and I am not sure why.
Here is the code where I let the user select a destination dir. At the end of the selection process it is supposed to update the ObjectListView of ActionsOlv with a timestamp and the action taken. Print statements are for debug only.
def onBrowseDest(self, event):
print "OnBrowseDest"
dest = selectFolder("Select the Destination Directory")
print dest
self.txDest.SetValue(dest)
self.anEvent = [Action(datetime.datetime.now(),dest,"Set as Destination dir")]
self.ActionsOlv.AddObject(self.anEvent)
What is occuring is that I see lines being created in the list, but there is not any content to the line. If I replace the AddObject method with SetObjects
self.ActionsOlv.SetObjects(self.anEvent)
it will update the display, but each newline overwites the list instead of adding to it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想通了这个问题。我需要使用 AddObjects,而不是 AddObject
I figured the issue out. I needed to use AddObjects, no AddObject