]> git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-13/list_icon.py
don't use strlen() to verify the length of the string as it can contain embedded...
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-13 / list_icon.py
1 import wx
2 import sys, glob
3
4 class DemoFrame(wx.Frame):
5 def __init__(self):
6 wx.Frame.__init__(self, None, -1,
7 "wx.ListCtrl in wx.LC_ICON mode",
8 size=(600,400))
9
10 # load some images into an image list
11 il = wx.ImageList(32,32, True)
12 for name in glob.glob("icon??.png"):
13 bmp = wx.Bitmap(name, wx.BITMAP_TYPE_PNG)
14 il_max = il.Add(bmp)
15
16 # create the list control
17 self.list = wx.ListCtrl(self, -1,
18 style=wx.LC_ICON | wx.LC_AUTOARRANGE)
19
20 # assign the image list to it
21 self.list.AssignImageList(il, wx.IMAGE_LIST_NORMAL)
22
23 # create some items for the list
24 for x in range(25):
25 img = x % (il_max+1)
26 self.list.InsertImageStringItem(x,
27 "This is item %02d" % x, img)
28
29 app = wx.PySimpleApp()
30 frame = DemoFrame()
31 frame.Show()
32 app.MainLoop()