]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxTreeListCtrl.py
replaced wxAppTraits::GetOSVersion with GetToolkitInfo with richer information that...
[wxWidgets.git] / wxPython / demo / wxTreeListCtrl.py
1
2 from wxPython.wx import *
3 from wxPython.gizmos import wxTreeListCtrl
4
5 import images
6
7 #----------------------------------------------------------------------
8
9 class TestPanel(wxPanel):
10 def __init__(self, parent, log):
11 self.log = log
12 wxPanel.__init__(self, parent, -1)
13 EVT_SIZE(self, self.OnSize)
14
15 self.tree = wxTreeListCtrl(self, -1, style = wxTR_DEFAULT_STYLE
16 #| wxTR_ROW_LINES
17 #| wxTR_NO_LINES | wxTR_TWIST_BUTTONS
18 )
19 isz = (16,16)
20 il = wxImageList(isz[0], isz[1])
21 fldridx = il.Add(wxArtProvider_GetBitmap(wxART_FOLDER, wxART_OTHER, isz))
22 fldropenidx = il.Add(wxArtProvider_GetBitmap(wxART_FILE_OPEN, wxART_OTHER, isz))
23 fileidx = il.Add(wxArtProvider_GetBitmap(wxART_REPORT_VIEW, wxART_OTHER, isz))
24 smileidx = il.Add(images.getSmilesBitmap())
25
26 self.tree.SetImageList(il)
27 self.il = il
28
29 # create some columns
30 self.tree.AddColumn("Main column")
31 self.tree.AddColumn("Column 1")
32 self.tree.AddColumn("Column 2")
33 self.tree.SetMainColumn(0) # the one with the tree in it...
34 self.tree.SetColumnWidth(0, 175)
35
36
37 self.root = self.tree.AddRoot("The Root Item")
38 self.tree.SetItemText(self.root, "col 1 root", 1)
39 self.tree.SetItemText(self.root, "col 2 root", 2)
40 self.tree.SetItemImage(self.root, fldridx, which = wxTreeItemIcon_Normal)
41 self.tree.SetItemImage(self.root, fldropenidx, which = wxTreeItemIcon_Expanded)
42
43
44 for x in range(15):
45 txt = "Item %d" % x
46 child = self.tree.AppendItem(self.root, txt)
47 self.tree.SetItemText(child, txt + "(c1)", 1)
48 self.tree.SetItemText(child, txt + "(c2)", 2)
49 self.tree.SetItemImage(child, fldridx, which = wxTreeItemIcon_Normal)
50 self.tree.SetItemImage(child, fldropenidx, which = wxTreeItemIcon_Expanded)
51
52 for y in range(5):
53 txt = "item %d-%s" % (x, chr(ord("a")+y))
54 last = self.tree.AppendItem(child, txt)
55 self.tree.SetItemText(last, txt + "(c1)", 1)
56 self.tree.SetItemText(last, txt + "(c2)", 2)
57 self.tree.SetItemImage(last, fldridx, which = wxTreeItemIcon_Normal)
58 self.tree.SetItemImage(last, fldropenidx, which = wxTreeItemIcon_Expanded)
59
60 for z in range(5):
61 txt = "item %d-%s-%d" % (x, chr(ord("a")+y), z)
62 item = self.tree.AppendItem(last, txt)
63 self.tree.SetItemText(item, txt + "(c1)", 1)
64 self.tree.SetItemText(item, txt + "(c2)", 2)
65 self.tree.SetItemImage(item, fileidx, which = wxTreeItemIcon_Normal)
66 self.tree.SetItemImage(item, smileidx, which = wxTreeItemIcon_Selected)
67
68
69 self.tree.Expand(self.root)
70
71
72 def OnSize(self, evt):
73 self.tree.SetSize(self.GetSize())
74
75
76 #----------------------------------------------------------------------
77
78 def runTest(frame, nb, log):
79 win = TestPanel(nb, log)
80 return win
81
82 #----------------------------------------------------------------------
83
84
85
86 overview = """<html><body>
87 <h2><center>wxTreeListCtrl</center></h2>
88
89 The wxTreeListCtrl is essentially a wxTreeCtrl with extra columns,
90 such that the look is similar to a wxListCtrl.
91
92 </body></html>
93 """
94
95
96
97
98 if __name__ == '__main__':
99 #raw_input("Press enter...")
100 import sys,os
101 import run
102 run.main(['', os.path.basename(sys.argv[0])])
103