jrosco
3/13/2014 - 11:23 AM

wx_image_test.py

import wx
import glob

""" Example at http://zetcode.com/wxpython/skeletons/ """


class DemoFrame(wx.Frame):
    def __init__(self):

        wx.Frame.__init__(self, None, -1, "wx.ListCtrl in wx.LC_REPORT mode", size=(600, 400))

        self.list = wx.ListCtrl(self, -1, style=wx.LC_REPORT | wx.LC_AUTOARRANGE)

        green_image = '../images/green-circle.png'
        red_image = '../images/red-circle.png'

        self.il = wx.ImageList(15, 15)

        green = self.il.Add(wx.Image(green_image, wx.BITMAP_TYPE_PNG).ConvertToBitmap())
        red = self.il.Add(wx.Image(red_image, wx.BITMAP_TYPE_PNG).ConvertToBitmap())

        self.list.AssignImageList(self.il, wx.IMAGE_LIST_SMALL)

        self.list.InsertColumn(0, 'text', width=100)
        self.list.InsertColumn(1, 'img', width=100)

        self.list.InsertStringItem(0, 'OK')
        self.list.SetItemImage(0, green)

        self.list.InsertStringItem(1, 'FAIL')
        self.list.SetItemImage(1, red)


app = wx.PySimpleApp()
frame = DemoFrame()
frame.Show()
app.MainLoop()