DataViewListCtrl: how to use AppendIconTextColumn

I’m sorry but I haven’t been able to find any examples for using AppendIconTextColumn in a DataViewListCtrl: how should I modify the following script in order to make the icon created with List.make_icon appear next to the ‘Test’ item?

···

####################################################
import wx
import wx.dataview

class List(wx.dataview.DataViewListCtrl):
def init(self, parent):
super(List, self).init(parent)
imagelist = wx.ImageList(16, 16)
imagelist.Add(self.make_icon())
self.AppendIconTextColumn(‘Test’, 0)
self.AppendItem((‘Test’, ))

def make_icon(self):
    bitmap = wx.EmptyBitmap(16, 16)
    dc = wx.MemoryDC()
    dc.SelectObject(bitmap)
    dc.SetBackground(wx.RED_BRUSH)
    dc.Clear()
    dc.SelectObject(wx.NullBitmap)
    return bitmap

app = wx.App()
frame = wx.Frame(None)
List(frame)
frame.Centre()
frame.Show()
app.MainLoop()
####################################################

dariogiova@gmail.com wrote:

I'm sorry but I haven't been able to find any examples for using
AppendIconTextColumn in a DataViewListCtrl: how should I modify the
following script in order to make the icon created with List.make_icon
appear next to the 'Test' item?

Instead of using a plain string in the data for the row, try using a wx.dataview.DataViewIconText. Like this:

    self.AppendItem( (wx.dataview.DataViewIconText('Text', icon),) )

···

--
Robin Dunn
Software Craftsman

Uh now I get it, that does work indeed, thank you!

···

On 15/03/14 12:49, Robin Dunn wrote:

dariogiova@gmail.com wrote:

I'm sorry but I haven't been able to find any examples for using
AppendIconTextColumn in a DataViewListCtrl: how should I modify the
following script in order to make the icon created with List.make_icon
appear next to the 'Test' item?

Instead of using a plain string in the data for the row, try using a wx.dataview.DataViewIconText. Like this:

   self.AppendItem( (wx.dataview.DataViewIconText('Text', icon),) )