]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/VirtualListCtrl.py
Updated wxSTC from Scintilla 1.40 to Scintilla 1.45
[wxWidgets.git] / wxPython / demo / VirtualListCtrl.py
CommitLineData
c7e7022c
RD
1
2
3from wxPython.wx import *
4
5#----------------------------------------------------------------------
6
7class TestVirtualList(wxListCtrl):
8 def __init__(self, parent, log):
9 wxListCtrl.__init__(self, parent, -1,
10 style=wxLC_REPORT|wxLC_VIRTUAL|wxLC_HRULES|wxLC_VRULES)
11 self.log = log
12
13 self.InsertColumn(0, "First")
14 self.InsertColumn(1, "Second")
15 self.InsertColumn(2, "Third")
16 self.SetColumnWidth(0, 175)
17 self.SetColumnWidth(1, 175)
18 self.SetColumnWidth(2, 175)
19
20 self.SetItemCount(1000000)
21
00b6c4e3
RD
22 self.attr1 = wxListItemAttr()
23 self.attr1.SetBackgroundColour("yellow")
c7e7022c 24
00b6c4e3
RD
25 self.attr2 = wxListItemAttr()
26 self.attr2.SetBackgroundColour("light blue")
c7e7022c 27
462f07ca
RD
28 EVT_LIST_ITEM_SELECTED(self, self.GetId(), self.OnItemSelected)
29 EVT_LIST_ITEM_ACTIVATED(self, self.GetId(), self.OnItemActivated)
c7e7022c 30
462f07ca
RD
31
32 def OnItemSelected(self, event):
33 self.currentItem = event.m_itemIndex
34 self.log.WriteText('OnItemSelected: "%s", "%s", "%s", "%s"\n' %
35 (self.currentItem,
36 self.GetItemText(self.currentItem),
37 self.getColumnText(self.currentItem, 1),
38 self.getColumnText(self.currentItem, 2)))
39
40 def OnItemActivated(self, event):
41 self.currentItem = event.m_itemIndex
42 self.log.WriteText("OnItemActivated: %s\n" % self.GetItemText(self.currentItem))
43
44 def getColumnText(self, index, col):
45 item = self.GetItem(index, col)
46 return item.GetText()
47
48 #---------------------------------------------------
49 # These methods are callbacks for implementing the
50 # "virtualness" of the list...
c7e7022c
RD
51 def OnGetItemText(self, item, col):
52 return "Item %d, column %d" % (item, col)
53
a1bfae9d 54
c7e7022c 55 def OnGetItemImage(self, item):
a1bfae9d
RD
56 return -1 # if used you should return the index in the ImageList
57
c7e7022c
RD
58
59 def OnGetItemAttr(self, item):
00b6c4e3
RD
60 if item % 3 == 1:
61 return self.attr1
62 elif item % 3 == 2:
63 return self.attr2
64 else:
65 return None
c7e7022c
RD
66
67
68#----------------------------------------------------------------------
69
70def runTest(frame, nb, log):
71 win = TestVirtualList(nb, log)
72 return win
73
74#----------------------------------------------------------------------
75
76
77
78
79
80
81
82
83overview = """\
84"""