1999-11-19 00:34:40 -05:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
import os
|
|
|
|
import sys
|
1999-11-19 00:34:40 -05:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
import wx
|
|
|
|
import wx.lib.mvctree as tree
|
1999-11-19 00:34:40 -05:00
|
|
|
|
|
|
|
logger = None
|
|
|
|
def selchanging(evt):
|
|
|
|
logger.write("SelChanging!\n")
|
|
|
|
|
|
|
|
def selchanged(evt):
|
|
|
|
logger.write("SelChange!\n")
|
|
|
|
logger.write(str(evt.node))
|
|
|
|
def expanded(evt):
|
|
|
|
logger.write("Expanded\n")
|
|
|
|
def closed(evt):
|
|
|
|
logger.write("Closed!\n")
|
|
|
|
def key(evt):
|
|
|
|
logger.write("Key\n")
|
|
|
|
def add(evt):
|
|
|
|
logger.write("Add\n")
|
|
|
|
def delitem(evt):
|
|
|
|
logger.write("Delete\n")
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
2003-12-22 14:09:54 -05:00
|
|
|
#f = wx.Frame(frame, -1, "MVCTree", (0,0), (200,500))
|
1999-11-19 00:34:40 -05:00
|
|
|
global logger
|
|
|
|
logger = log
|
2003-12-22 14:09:54 -05:00
|
|
|
p = tree.MVCTree(nb, -1)
|
|
|
|
#f = wx.Frame(frame, -1, "MVCTree")
|
|
|
|
#p = tree.MVCTree(f, -1)
|
2003-03-25 01:35:27 -05:00
|
|
|
p.SetAssumeChildren(True)
|
2003-12-08 20:23:28 -05:00
|
|
|
p.SetModel(tree.LateFSTreeModel(os.path.normpath(os.getcwd() + os.sep +'..')))
|
|
|
|
|
1999-11-19 00:34:40 -05:00
|
|
|
#Uncomment this to enable live filename editing!
|
|
|
|
# p.AddEditor(FileEditor(p))
|
2003-12-08 20:23:28 -05:00
|
|
|
|
2003-03-25 01:35:27 -05:00
|
|
|
p.SetMultiSelect(True)
|
2003-12-08 20:23:28 -05:00
|
|
|
tree.EVT_MVCTREE_SEL_CHANGING(p, p.GetId(), selchanging)
|
|
|
|
tree.EVT_MVCTREE_SEL_CHANGED(p, p.GetId(), selchanged)
|
|
|
|
tree.EVT_MVCTREE_ITEM_EXPANDED(p, p.GetId(), expanded)
|
|
|
|
tree.EVT_MVCTREE_ITEM_COLLAPSED(p, p.GetId(), closed)
|
|
|
|
tree.EVT_MVCTREE_ADD_ITEM(p, p.GetId(), add)
|
|
|
|
tree.EVT_MVCTREE_DELETE_ITEM(p, p.GetId(), delitem)
|
|
|
|
tree.EVT_MVCTREE_KEY_DOWN(p, p.GetId(), key)
|
2000-02-13 01:01:58 -05:00
|
|
|
|
1999-11-19 00:34:40 -05:00
|
|
|
return p
|
2000-02-13 01:01:58 -05:00
|
|
|
#frame.otherWin = f
|
2003-03-25 01:35:27 -05:00
|
|
|
#f.Show(True)
|
2000-02-13 01:01:58 -05:00
|
|
|
#return None
|
|
|
|
|
|
|
|
|
1999-11-19 00:34:40 -05:00
|
|
|
overview = """\
|
2003-07-02 19:13:10 -04:00
|
|
|
|
2003-12-22 14:09:54 -05:00
|
|
|
MVCTree is a control which handles hierarchical data. It is
|
2003-07-02 19:13:10 -04:00
|
|
|
constructed in model-view-controller architecture, so the display of
|
|
|
|
that data, and the content of the data can be changed greatly without
|
|
|
|
affecting the other parts.
|
1999-11-19 00:34:40 -05:00
|
|
|
|
|
|
|
Multiple selections are possible by holding down the Ctrl key.
|
|
|
|
|
2003-07-02 19:13:10 -04:00
|
|
|
This demo shows the wxPython directory structure. The interesting part
|
|
|
|
is that the tree model is late-bound to the filesystem, so the
|
|
|
|
filenames are not retrieved until the directory is expanded. In
|
|
|
|
mvctree.py are models for generic data, and both the early and
|
|
|
|
late-bound filesystem models.
|
1999-11-19 00:34:40 -05:00
|
|
|
|
2003-07-02 19:13:10 -04:00
|
|
|
There is also support for editing, though it's not enabled in this
|
|
|
|
demo, to avoid accidentally renaming files!
|
1999-11-19 00:34:40 -05:00
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2003-07-02 19:13:10 -04:00
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-04 19:06:33 -05:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|