]> git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-13/list_report.py
pixbuf cursor support is for GTK 2.4.
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-13 / list_report.py
1 import wx
2 import sys, glob, random
3 import data
4
5 class DemoFrame(wx.Frame):
6 def __init__(self):
7 wx.Frame.__init__(self, None, -1,
8 "wx.ListCtrl in wx.LC_REPORT mode",
9 size=(600,400))
10
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 self.list = wx.ListCtrl(self, -1, style=wx.LC_REPORT)
16 self.list.AssignImageList(il, wx.IMAGE_LIST_SMALL)
17
18 # Add some columns
19 for col, text in enumerate(data.columns):
20 self.list.InsertColumn(col, text)
21
22 # add the rows
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)
27
28 # give each item a random image
29 img = random.randint(0, il_max)
30 self.list.SetItemImage(index, img, img)
31
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)
37
38
39 app = wx.PySimpleApp()
40 frame = DemoFrame()
41 frame.Show()
42 app.MainLoop()