]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-13/list_report.py
2 import sys
, glob
, random
5 class DemoFrame(wx
.Frame
):
7 wx
.Frame
.__init
__(self
, None, -1,
8 "wx.ListCtrl in wx.LC_REPORT mode",
11 il
= wx
.ImageList(16,16, True)
12 for name
in glob
.glob("smicon??.png"):
13 bmp
= wx
.Bitmap(name
, wx
.BITMAP_TYPE_PNG
)
15 self
.list = wx
.ListCtrl(self
, -1, style
=wx
.LC_REPORT
)
16 self
.list.AssignImageList(il
, wx
.IMAGE_LIST_SMALL
)
19 for col
, text
in enumerate(data
.columns
):
20 self
.list.InsertColumn(col
, text
)
23 for item
in data
.rows
:
24 index
= self
.list.InsertStringItem(sys
.maxint
, item
[0])
25 for col
, text
in enumerate(item
[1:]):
26 self
.list.SetStringItem(index
, col
+1, text
)
28 # give each item a random image
29 img
= random
.randint(0, il_max
)
30 self
.list.SetItemImage(index
, img
, img
)
32 # set the width of the columns in various ways
33 self
.list.SetColumnWidth(0, 120)
34 self
.list.SetColumnWidth(1, wx
.LIST_AUTOSIZE
)
35 self
.list.SetColumnWidth(2, wx
.LIST_AUTOSIZE
)
36 self
.list.SetColumnWidth(3, wx
.LIST_AUTOSIZE_USEHEADER
)
39 app
= wx
.PySimpleApp()