forked from wxWidgets/Phoenix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDVC_ListCtrl.py
69 lines (46 loc) · 1.87 KB
/
DVC_ListCtrl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
import wx
import wx.dataview as dv
#----------------------------------------------------------------------
# Reuse the music data in the ListCtrl sample
import ListCtrl
musicdata = sorted(ListCtrl.musicdata.items())
#musicdata.sort()
musicdata = [[str(k)] + list(v) for k,v in musicdata]
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
# create the listctrl
self.dvlc = dvlc = dv.DataViewListCtrl(self)
# Give it some columns.
# The ID col we'll customize a bit:
dvlc.AppendTextColumn('id', width=40)
dvlc.AppendTextColumn('artist', width=170)
dvlc.AppendTextColumn('title', width=260)
dvlc.AppendTextColumn('genre', width=80)
# Load the data. Each item (row) is added as a sequence of values
# whose order matches the columns
for itemvalues in musicdata:
dvlc.AppendItem(itemvalues)
# Set the layout so the listctrl fills the panel
self.Sizer = wx.BoxSizer()
self.Sizer.Add(dvlc, 1, wx.EXPAND)
#----------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#----------------------------------------------------------------------
overview = """<html><body>
<h2><center>DataViewListCtrl</center></h2>
The DataViewListCtrl class is much like the traditional wx.ListCtrl in report
mode, in that it stores all items itself and all access to the data is through
the list ctrl's API. However it is derived from DataViewCtrl and uses a model
class internally, so it also has many of the benefits of the data view classes
available as well.
</body></html>
"""
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])