]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/demo/wxTreeCtrl.py
jconfig.h uses configures results
[wxWidgets.git] / utils / wxPython / demo / wxTreeCtrl.py
CommitLineData
cf694132
RD
1
2from wxPython.wx import *
3
4#---------------------------------------------------------------------------
5
6class TestTreeCtrlPanel(wxPanel):
7 def __init__(self, parent, log):
8 wxPanel.__init__(self, parent, -1)
9
10 self.log = log
11 tID = NewId()
12
13 self.tree = wxTreeCtrl(self, tID)
14 root = self.tree.AddRoot("The Root Item")
15 for x in range(15):
16 child = self.tree.AppendItem(root, "Item %d" % x)
17 for y in range(5):
18 last = self.tree.AppendItem(child, "item %d-%s" % (x, chr(ord("a")+y)))
19 for z in range(5):
20 self.tree.AppendItem(last, "item %d-%s-%d" % (x, chr(ord("a")+y), z))
21
22 self.tree.Expand(root)
23 EVT_TREE_ITEM_EXPANDED (self, tID, self.OnItemExpanded)
24 EVT_TREE_ITEM_COLLAPSED (self, tID, self.OnItemCollapsed)
25 EVT_TREE_SEL_CHANGED (self, tID, self.OnSelChanged)
26
27
28 def OnSize(self, event):
29 w,h = self.GetClientSizeTuple()
30 self.tree.SetDimensions(0, 0, w, h)
31
32
33 def OnItemExpanded(self, event):
34 item = event.GetItem()
35 self.log.WriteText("OnItemExpanded: %s\n" % self.tree.GetItemText(item))
36
37 def OnItemCollapsed(self, event):
38 item = event.GetItem()
39 self.log.WriteText("OnItemCollapsed: %s\n" % self.tree.GetItemText(item))
40
41 def OnSelChanged(self, event):
42 item = event.GetItem()
43 self.log.WriteText("OnSelChanged: %s\n" % self.tree.GetItemText(item))
44
45#---------------------------------------------------------------------------
46
47def runTest(frame, nb, log):
48 win = TestTreeCtrlPanel(nb, log)
49 return win
50
51#---------------------------------------------------------------------------
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70overview = """\
71A tree control presents information as a hierarchy, with items that may be expanded to show further items. Items in a tree control are referenced by wxTreeItemId handles.
72
73wxTreeCtrl()
74-------------------------
75
76Default constructor.
77
78wxTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTR_HAS_BUTTONS, const wxValidator& validator = wxDefaultValidator, const wxString& name = "listCtrl")
79
80Constructor, creating and showing a tree control.
81
82Parameters
83-------------------
84
85parent = Parent window. Must not be NULL.
86
87id = Window identifier. A value of -1 indicates a default value.
88
89pos = Window position.
90
91size = Window size. If the default size (-1, -1) is specified then the window is sized appropriately.
92
93style = Window style. See wxTreeCtrl.
94
95validator = Window validator.
96
97name = Window name.
98"""