]>
Commit | Line | Data |
---|---|---|
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_SMALL_ICON mode", | |
8 | size=(600,400)) | |
9 | ||
10 | # load some images into an image list | |
11 | il = wx.ImageList(16,16, True) | |
12 | for name in glob.glob("smicon??.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_SMALL_ICON | |
19 | | wx.LC_AUTOARRANGE | |
20 | ) | |
21 | ||
22 | # assign the image list to it | |
23 | self.list.AssignImageList(il, wx.IMAGE_LIST_SMALL) | |
24 | ||
25 | # create some items for the list | |
26 | for x in range(25): | |
27 | img = x % (il_max+1) | |
28 | self.list.InsertImageStringItem(x, | |
29 | "This is item %02d" % x, | |
30 | img) | |
31 | ||
32 | app = wx.PySimpleApp() | |
33 | frame = DemoFrame() | |
34 | frame.Show() | |
35 | app.MainLoop() |