Adding items to an object with ObjectListView

Deadly 提交于 2019-12-11 07:36:40

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/5009142/adding-items-to-an-object-with-objectlistview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!