Search code examples
pythonwxpythonwxwidgets

How to set an array to ListCtrl


I want to set an array into a wxListCtrl.

Similar to the Set function when using wx.ListBox or the SetItems function when using wx.ComboBox.

On the wxpython API there only seems to be an Append function.


Solution

  • I don't see an easy way to do this in the API other than just using a loop. There is a weird example in the wxPython demo for the ListCtrl where they somehow set a dict as the data for the list control. You might like that. Alternatively, I enjoy using the ObjectListView widget (http://pypi.python.org/pypi/ObjectListView) as I find it easier to use anyway.

    In wxPython 2.9, there's the new DVC_ListCtrl, but it also probably needs a loop.