]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/MVCTree.py
An icon for the doc viewer
[wxWidgets.git] / wxPython / demo / MVCTree.py
... / ...
CommitLineData
1
2import os
3import sys
4
5import wx
6import wx.lib.mvctree as tree
7
8logger = None
9def selchanging(evt):
10 logger.write("SelChanging!\n")
11
12def selchanged(evt):
13 logger.write("SelChange!\n")
14 logger.write(str(evt.node))
15def expanded(evt):
16 logger.write("Expanded\n")
17def closed(evt):
18 logger.write("Closed!\n")
19def key(evt):
20 logger.write("Key\n")
21def add(evt):
22 logger.write("Add\n")
23def delitem(evt):
24 logger.write("Delete\n")
25
26def runTest(frame, nb, log):
27 #f = wx.Frame(frame, -1, "MVCTree", (0,0), (200,500))
28 global logger
29 logger = log
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 +'..')))
35
36 #Uncomment this to enable live filename editing!
37# p.AddEditor(FileEditor(p))
38
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)
47
48 return p
49 #frame.otherWin = f
50 #f.Show(True)
51 #return None
52
53
54overview = """\
55
56MVCTree is a control which handles hierarchical data. It is
57constructed in model-view-controller architecture, so the display of
58that data, and the content of the data can be changed greatly without
59affecting the other parts.
60
61Multiple selections are possible by holding down the Ctrl key.
62
63This demo shows the wxPython directory structure. The interesting part
64is that the tree model is late-bound to the filesystem, so the
65filenames are not retrieved until the directory is expanded. In
66mvctree.py are models for generic data, and both the early and
67late-bound filesystem models.
68
69There is also support for editing, though it's not enabled in this
70demo, to avoid accidentally renaming files!
71
72"""
73
74
75if __name__ == '__main__':
76 import sys,os
77 import run
78 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])