]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/MVCTree.py
fixed compile error
[wxWidgets.git] / wxPython / demo / MVCTree.py
CommitLineData
e395c057 1
8fa876ca
RD
2import os
3import sys
e395c057 4
8fa876ca
RD
5import wx
6import wx.lib.mvctree as tree
e395c057
RD
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):
d4b73b1b 27 #f = wx.Frame(frame, -1, "MVCTree", (0,0), (200,500))
e395c057
RD
28 global logger
29 logger = log
d4b73b1b
RD
30 p = tree.MVCTree(nb, -1)
31 #f = wx.Frame(frame, -1, "MVCTree")
32 #p = tree.MVCTree(f, -1)
1e4a197e 33 p.SetAssumeChildren(True)
8fa876ca
RD
34 p.SetModel(tree.LateFSTreeModel(os.path.normpath(os.getcwd() + os.sep +'..')))
35
e395c057
RD
36 #Uncomment this to enable live filename editing!
37# p.AddEditor(FileEditor(p))
8fa876ca 38
1e4a197e 39 p.SetMultiSelect(True)
8fa876ca
RD
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)
854862f5 47
e395c057 48 return p
854862f5 49 #frame.otherWin = f
1e4a197e 50 #f.Show(True)
854862f5
RD
51 #return None
52
53
e395c057 54overview = """\
1fded56b 55
d4b73b1b 56MVCTree is a control which handles hierarchical data. It is
1fded56b
RD
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.
e395c057
RD
60
61Multiple selections are possible by holding down the Ctrl key.
62
1fded56b
RD
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.
e395c057 68
1fded56b
RD
69There is also support for editing, though it's not enabled in this
70demo, to avoid accidentally renaming files!
e395c057
RD
71
72"""
73
74
1fded56b
RD
75if __name__ == '__main__':
76 import sys,os
77 import run
8eca4fef 78 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])