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