]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/MVCTree.py
6 import wx
.lib
.mvctree
as tree
10 logger
.write("SelChanging!\n")
13 logger
.write("SelChange!\n")
14 logger
.write(str(evt
.node
))
16 logger
.write("Expanded\n")
18 logger
.write("Closed!\n")
24 logger
.write("Delete\n")
26 def runTest(frame
, nb
, log
):
27 #f = wx.Frame(frame, -1, "MVCTree", (0,0), (200,500))
30 p
= tree
.MVCTree(nb
, -1)
31 #f = wx.Frame(frame, -1, "MVCTree")
32 #p = tree.MVCTree(f, -1)
33 p
.SetAssumeChildren(True)
34 p
.SetModel(tree
.LateFSTreeModel(os
.path
.normpath(os
.getcwd() + os
.sep
+'..')))
36 #Uncomment this to enable live filename editing!
37 # p.AddEditor(FileEditor(p))
39 p
.SetMultiSelect(True)
40 tree
.EVT_MVCTREE_SEL_CHANGING(p
, p
.GetId(), selchanging
)
41 tree
.EVT_MVCTREE_SEL_CHANGED(p
, p
.GetId(), selchanged
)
42 tree
.EVT_MVCTREE_ITEM_EXPANDED(p
, p
.GetId(), expanded
)
43 tree
.EVT_MVCTREE_ITEM_COLLAPSED(p
, p
.GetId(), closed
)
44 tree
.EVT_MVCTREE_ADD_ITEM(p
, p
.GetId(), add
)
45 tree
.EVT_MVCTREE_DELETE_ITEM(p
, p
.GetId(), delitem
)
46 tree
.EVT_MVCTREE_KEY_DOWN(p
, p
.GetId(), key
)
56 MVCTree is a control which handles hierarchical data. It is
57 constructed in model-view-controller architecture, so the display of
58 that data, and the content of the data can be changed greatly without
59 affecting the other parts.
61 Multiple selections are possible by holding down the Ctrl key.
63 This demo shows the wxPython directory structure. The interesting part
64 is that the tree model is late-bound to the filesystem, so the
65 filenames are not retrieved until the directory is expanded. In
66 mvctree.py are models for generic data, and both the early and
67 late-bound filesystem models.
69 There is also support for editing, though it's not enabled in this
70 demo, to avoid accidentally renaming files!
75 if __name__
== '__main__':
78 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])