]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/MVCTree.py
made main toolbar bitmaps 24x24
[wxWidgets.git] / wxPython / demo / MVCTree.py
1
2 import os
3 import sys
4
5 import wx
6 import wx.lib.mvctree as tree
7
8 logger = None
9 def selchanging(evt):
10 logger.write("SelChanging!\n")
11
12 def selchanged(evt):
13 logger.write("SelChange!\n")
14 logger.write(str(evt.node))
15 def expanded(evt):
16 logger.write("Expanded\n")
17 def closed(evt):
18 logger.write("Closed!\n")
19 def key(evt):
20 logger.write("Key\n")
21 def add(evt):
22 logger.write("Add\n")
23 def delitem(evt):
24 logger.write("Delete\n")
25
26 def 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
54 overview = """\
55
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.
60
61 Multiple selections are possible by holding down the Ctrl key.
62
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.
68
69 There is also support for editing, though it's not enabled in this
70 demo, to avoid accidentally renaming files!
71
72 """
73
74
75 if __name__ == '__main__':
76 import sys,os
77 import run
78 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])