3 from wxPython
.wx
import *
5 #----------------------------------------------------------------------
7 class TestVirtualList(wxListCtrl
):
8 def __init__(self
, parent
, log
):
9 wxListCtrl
.__init
__(self
, parent
, -1,
10 style
=wxLC_REPORT|wxLC_VIRTUAL|wxLC_HRULES|wxLC_VRULES
)
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)
20 self
.SetItemCount(1000000)
22 self
.attr1
= wxListItemAttr()
23 self
.attr1
.SetBackgroundColour("yellow")
25 self
.attr2
= wxListItemAttr()
26 self
.attr2
.SetBackgroundColour("light blue")
28 EVT_LIST_ITEM_SELECTED(self
, self
.GetId(), self
.OnItemSelected
)
29 EVT_LIST_ITEM_ACTIVATED(self
, self
.GetId(), self
.OnItemActivated
)
32 def OnItemSelected(self
, event
):
33 self
.currentItem
= event
.m_itemIndex
34 self
.log
.WriteText('OnItemSelected: "%s", "%s", "%s", "%s"\n' %
36 self
.GetItemText(self
.currentItem
),
37 self
.getColumnText(self
.currentItem
, 1),
38 self
.getColumnText(self
.currentItem
, 2)))
40 def OnItemActivated(self
, event
):
41 self
.currentItem
= event
.m_itemIndex
42 self
.log
.WriteText("OnItemActivated: %s\n" % self
.GetItemText(self
.currentItem
))
44 def getColumnText(self
, index
, col
):
45 item
= self
.GetItem(index
, col
)
48 #---------------------------------------------------
49 # These methods are callbacks for implementing the
50 # "virtualness" of the list...
51 def OnGetItemText(self
, item
, col
):
52 return "Item %d, column %d" % (item
, col
)
55 def OnGetItemImage(self
, item
):
56 return -1 # if used you should return the index in the ImageList
59 def OnGetItemAttr(self
, item
):
68 #----------------------------------------------------------------------
70 def runTest(frame
, nb
, log
):
71 win
= TestVirtualList(nb
, log
)
74 #----------------------------------------------------------------------