]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxMVCTree.py
1 # 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
3 # o Updated for wx namespace
5 # 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net)
7 # o Library must be updated for this to run.
14 import wx
.lib
.mvctree
as tree
18 logger
.write("SelChanging!\n")
21 logger
.write("SelChange!\n")
22 logger
.write(str(evt
.node
))
24 logger
.write("Expanded\n")
26 logger
.write("Closed!\n")
32 logger
.write("Delete\n")
34 def runTest(frame
, nb
, log
):
35 #f = wx.Frame(frame, -1, "wxMVCTree", (0,0), (200,500))
38 p
= tree
.wxMVCTree(nb
, -1)
39 #f = wx.Frame(frame, -1, "wxMVCTree")
40 #p = tree.wxMVCTree(f, -1)
41 p
.SetAssumeChildren(True)
42 p
.SetModel(tree
.LateFSTreeModel(os
.path
.normpath(os
.getcwd() + os
.sep
+'..')))
44 #Uncomment this to enable live filename editing!
45 # p.AddEditor(FileEditor(p))
47 p
.SetMultiSelect(True)
48 tree
.EVT_MVCTREE_SEL_CHANGING(p
, p
.GetId(), selchanging
)
49 tree
.EVT_MVCTREE_SEL_CHANGED(p
, p
.GetId(), selchanged
)
50 tree
.EVT_MVCTREE_ITEM_EXPANDED(p
, p
.GetId(), expanded
)
51 tree
.EVT_MVCTREE_ITEM_COLLAPSED(p
, p
.GetId(), closed
)
52 tree
.EVT_MVCTREE_ADD_ITEM(p
, p
.GetId(), add
)
53 tree
.EVT_MVCTREE_DELETE_ITEM(p
, p
.GetId(), delitem
)
54 tree
.EVT_MVCTREE_KEY_DOWN(p
, p
.GetId(), key
)
64 wxMVCTree is a control which handles hierarchical data. It is
65 constructed in model-view-controller architecture, so the display of
66 that data, and the content of the data can be changed greatly without
67 affecting the other parts.
69 Multiple selections are possible by holding down the Ctrl key.
71 This demo shows the wxPython directory structure. The interesting part
72 is that the tree model is late-bound to the filesystem, so the
73 filenames are not retrieved until the directory is expanded. In
74 mvctree.py are models for generic data, and both the early and
75 late-bound filesystem models.
77 There is also support for editing, though it's not enabled in this
78 demo, to avoid accidentally renaming files!
83 if __name__
== '__main__':
86 run
.main(['', os
.path
.basename(sys
.argv
[0])])