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