]>
Commit | Line | Data |
---|---|---|
e395c057 | 1 | |
8fa876ca RD |
2 | import os |
3 | import sys | |
e395c057 | 4 | |
8fa876ca RD |
5 | import wx |
6 | import wx.lib.mvctree as tree | |
e395c057 RD |
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): | |
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 | 54 | overview = """\ |
1fded56b | 55 | |
d4b73b1b | 56 | MVCTree is a control which handles hierarchical data. It is |
1fded56b RD |
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. | |
e395c057 RD |
60 | |
61 | Multiple selections are possible by holding down the Ctrl key. | |
62 | ||
1fded56b RD |
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. | |
e395c057 | 68 | |
1fded56b RD |
69 | There is also support for editing, though it's not enabled in this |
70 | demo, to avoid accidentally renaming files! | |
e395c057 RD |
71 | |
72 | """ | |
73 | ||
74 | ||
1fded56b RD |
75 | if __name__ == '__main__': |
76 | import sys,os | |
77 | import run | |
8eca4fef | 78 | run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) |