使用 ObjectListView 向对象添加项目 [英] Adding items to an object with ObjectListView

查看:38
本文介绍了使用 ObjectListView 向对象添加项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读这里的一些项目后,我决定使用 ObjectListView 重写一个小项目.我的问题是,当我尝试执行 self.ListObject.AddObject(object) 将一个项目添加到我的列表时它失败了,我不知道为什么.

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.

这是我让用户选择目标目录的代码.在选择过程结束时,它应该使用时间戳和所采取的操作更新 ActionsOlv 的 ObjectListView.打印语句仅用于调试.

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)

发生的情况是我看到列表中正在创建行,但该行没有任何内容.如果我用 SetObjects 替换 AddObject 方法

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.

推荐答案

我想出了这个问题.我需要使用 AddObjects,没有 AddObject

I figured the issue out. I needed to use AddObjects, no AddObject

这篇关于使用 ObjectListView 向对象添加项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆