]>
Commit | Line | Data |
---|---|---|
8fa876ca RD |
1 | # 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) |
2 | # | |
3 | # o Updated for wx namespace | |
4 | # | |
5 | # 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) | |
6 | # | |
7 | # o Library must be updated for this to run. | |
8 | # | |
d4b73b1b RD |
9 | # 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) |
10 | # | |
11 | # o wxMVCTree -> MVCTree | |
12 | # | |
e395c057 | 13 | |
8fa876ca RD |
14 | import os |
15 | import sys | |
e395c057 | 16 | |
8fa876ca RD |
17 | import wx |
18 | import wx.lib.mvctree as tree | |
e395c057 RD |
19 | |
20 | logger = None | |
21 | def selchanging(evt): | |
22 | logger.write("SelChanging!\n") | |
23 | ||
24 | def selchanged(evt): | |
25 | logger.write("SelChange!\n") | |
26 | logger.write(str(evt.node)) | |
27 | def expanded(evt): | |
28 | logger.write("Expanded\n") | |
29 | def closed(evt): | |
30 | logger.write("Closed!\n") | |
31 | def key(evt): | |
32 | logger.write("Key\n") | |
33 | def add(evt): | |
34 | logger.write("Add\n") | |
35 | def delitem(evt): | |
36 | logger.write("Delete\n") | |
37 | ||
38 | def runTest(frame, nb, log): | |
d4b73b1b | 39 | #f = wx.Frame(frame, -1, "MVCTree", (0,0), (200,500)) |
e395c057 RD |
40 | global logger |
41 | logger = log | |
d4b73b1b RD |
42 | p = tree.MVCTree(nb, -1) |
43 | #f = wx.Frame(frame, -1, "MVCTree") | |
44 | #p = tree.MVCTree(f, -1) | |
1e4a197e | 45 | p.SetAssumeChildren(True) |
8fa876ca RD |
46 | p.SetModel(tree.LateFSTreeModel(os.path.normpath(os.getcwd() + os.sep +'..'))) |
47 | ||
e395c057 RD |
48 | #Uncomment this to enable live filename editing! |
49 | # p.AddEditor(FileEditor(p)) | |
8fa876ca | 50 | |
1e4a197e | 51 | p.SetMultiSelect(True) |
8fa876ca RD |
52 | tree.EVT_MVCTREE_SEL_CHANGING(p, p.GetId(), selchanging) |
53 | tree.EVT_MVCTREE_SEL_CHANGED(p, p.GetId(), selchanged) | |
54 | tree.EVT_MVCTREE_ITEM_EXPANDED(p, p.GetId(), expanded) | |
55 | tree.EVT_MVCTREE_ITEM_COLLAPSED(p, p.GetId(), closed) | |
56 | tree.EVT_MVCTREE_ADD_ITEM(p, p.GetId(), add) | |
57 | tree.EVT_MVCTREE_DELETE_ITEM(p, p.GetId(), delitem) | |
58 | tree.EVT_MVCTREE_KEY_DOWN(p, p.GetId(), key) | |
854862f5 | 59 | |
e395c057 | 60 | return p |
854862f5 | 61 | #frame.otherWin = f |
1e4a197e | 62 | #f.Show(True) |
854862f5 RD |
63 | #return None |
64 | ||
65 | ||
e395c057 | 66 | overview = """\ |
1fded56b | 67 | |
d4b73b1b | 68 | MVCTree is a control which handles hierarchical data. It is |
1fded56b RD |
69 | constructed in model-view-controller architecture, so the display of |
70 | that data, and the content of the data can be changed greatly without | |
71 | affecting the other parts. | |
e395c057 RD |
72 | |
73 | Multiple selections are possible by holding down the Ctrl key. | |
74 | ||
1fded56b RD |
75 | This demo shows the wxPython directory structure. The interesting part |
76 | is that the tree model is late-bound to the filesystem, so the | |
77 | filenames are not retrieved until the directory is expanded. In | |
78 | mvctree.py are models for generic data, and both the early and | |
79 | late-bound filesystem models. | |
e395c057 | 80 | |
1fded56b RD |
81 | There is also support for editing, though it's not enabled in this |
82 | demo, to avoid accidentally renaming files! | |
e395c057 RD |
83 | |
84 | """ | |
85 | ||
86 | ||
1fded56b RD |
87 | if __name__ == '__main__': |
88 | import sys,os | |
89 | import run | |
90 | run.main(['', os.path.basename(sys.argv[0])]) |