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