]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxTreeListCtrl.py
2 from wxPython
.wx
import *
3 from wxPython
.gizmos
import wxTreeListCtrl
7 #----------------------------------------------------------------------
9 class TestPanel(wxPanel
):
10 def __init__(self
, parent
, log
):
12 wxPanel
.__init
__(self
, parent
, -1)
13 EVT_SIZE(self
, self
.OnSize
)
15 self
.tree
= wxTreeListCtrl(self
, -1, style
= wxTR_DEFAULT_STYLE
17 #| wxTR_NO_LINES | wxTR_TWIST_BUTTONS
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())
26 self
.tree
.SetImageList(il
)
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)
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
)
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
)
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
)
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
)
69 self
.tree
.Expand(self
.root
)
72 def OnSize(self
, evt
):
73 self
.tree
.SetSize(self
.GetSize())
76 #----------------------------------------------------------------------
78 def runTest(frame
, nb
, log
):
79 win
= TestPanel(nb
, log
)
82 #----------------------------------------------------------------------
86 overview
= """<html><body>
87 <h2><center>wxTreeListCtrl</center></h2>
89 The wxTreeListCtrl is essentially a wxTreeCtrl with extra columns,
90 such that the look is similar to a wxListCtrl.
98 if __name__
== '__main__':
99 #raw_input("Press enter...")
102 run
.main(['', os
.path
.basename(sys
.argv
[0])])