dabodemo Commit
Revision 325
Date: 2005-10-20 09:00:34 -0700 (Thu, 20 Oct 2005)
Author: adi

Changed:
U   trunk/wxPython-demos/demos/dBitmap.py
U   trunk/wxPython-demos/demos/dBox.py
U   trunk/wxPython-demos/demos/dCheckBox.py
U   trunk/wxPython-demos/demos/dColorDialog.py
U   trunk/wxPython-demos/treedata.py

Log:
build the demos tree from data within the demo files. Each demo file now 
contains a line "# node: Basic Controls/dButton" which supplies the position 
within the demo tree. There can be multiple node: lines in one demo file.


Diff:
Modified: trunk/wxPython-demos/demos/dBitmap.py
===================================================================
--- trunk/wxPython-demos/demos/dBitmap.py       2005-10-20 15:57:02 UTC (rev 
324)
+++ trunk/wxPython-demos/demos/dBitmap.py       2005-10-20 16:00:34 UTC (rev 
325)
@@ -1,3 +1,4 @@
+# node:Basic controls/dBitmap
 import dabo
 import os
 
@@ -46,4 +47,5 @@
        return win
 
 overView = """Demonstrates the use of a dBitmap.
-"""
\ No newline at end of file
+"""
+

Modified: trunk/wxPython-demos/demos/dBox.py
===================================================================
--- trunk/wxPython-demos/demos/dBox.py  2005-10-20 15:57:02 UTC (rev 324)
+++ trunk/wxPython-demos/demos/dBox.py  2005-10-20 16:00:34 UTC (rev 325)
@@ -1,3 +1,4 @@
+# node:Basic controls/dBox
 import dabo
 
 class TestPanel(dabo.ui.dPanel):

Modified: trunk/wxPython-demos/demos/dCheckBox.py
===================================================================
--- trunk/wxPython-demos/demos/dCheckBox.py     2005-10-20 15:57:02 UTC (rev 
324)
+++ trunk/wxPython-demos/demos/dCheckBox.py     2005-10-20 16:00:34 UTC (rev 
325)
@@ -1,3 +1,4 @@
+# node:Basic controls/dCheckBox
 import dabo
 
 class TestPanel(dabo.ui.dPanel):

Modified: trunk/wxPython-demos/demos/dColorDialog.py
===================================================================
--- trunk/wxPython-demos/demos/dColorDialog.py  2005-10-20 15:57:02 UTC (rev 
324)
+++ trunk/wxPython-demos/demos/dColorDialog.py  2005-10-20 16:00:34 UTC (rev 
325)
@@ -1,3 +1,4 @@
+# node:Basic controls/dColordialog
 import dabo
 
 class TestPanel(dabo.ui.dPanel):

Modified: trunk/wxPython-demos/treedata.py
===================================================================
--- trunk/wxPython-demos/treedata.py    2005-10-20 15:57:02 UTC (rev 324)
+++ trunk/wxPython-demos/treedata.py    2005-10-20 16:00:34 UTC (rev 325)
@@ -1,19 +1,65 @@
+import os
 import os.path
+import re
 
 import lib
 
 Nodes = []
-node = lib.TreeNode('Basic Controls')
-node.addChild('dBox', os.path.join('demos','dBox.py'))
-node.addChild('dBitmap', os.path.join('demos','dBitmap.py'))
-node.addChild('dCheckBox', os.path.join('demos','dCheckBox.py'))
-Nodes.append(node)
 
-node = lib.TreeNode('Standard Dialogs')
-node.addChild('dColorDialog', os.path.join('demos','dColorDialog.py'))
-Nodes.append(node)
+node_regex = re.compile("[\s]*#[\s]*node:[\s]*(.*)[\s]*")
 
-node = lib.TreeNode('Sizers')
-node.addChild('dynamic sizers manipulation', os.path.join('tutorial', 
'sizerExample.py'))
-Nodes.append(node)
-del node
+def findOrAddLevel(tree, level):
+       found = False
+       for node in tree:
+               if node.Label == level:
+                       found = True
+                       break
+       if found == True:
+               ret = node
+       else:
+               ret = lib.TreeNode(level)
+               tree.append(ret)
+       return ret
+
+def addNode(fn):
+       f = file(fn,'r')
+       isinstance(f,file)
+       demo_nodes = []
+       found = None
+       for line in f:
+               isinstance(line,str)
+               line = line.strip('\n')
+               node_pos = node_regex.findall(line)
+               if len(node_pos):
+                       found = True
+                       demo_nodes = demo_nodes + node_pos
+               else:
+                       if found == True:
+                               break
+
+       for pos in demo_nodes:
+               hierarchie = pos.split('/')
+               isinstance(hierarchie, list)
+               desc = hierarchie.pop()
+               
+               parent = Nodes
+               for level in hierarchie:
+                       parent = findOrAddLevel(parent, level)
+                       parent = parent.Children
+                       
+               demo = lib.TreeNode(desc,fn)
+               parent.append(demo)
+               
+def buildNodes(arg,dir,filenames):
+       for file in filenames:
+               path = os.path.join(dir, file)
+               isinstance(filenames,list)
+               isinstance(path,str)
+               if os.path.isdir(path):
+                       filenames.remove(file)
+                       continue
+               if os.path.isfile(path) and path[-3:] == '.py':
+                       addNode(path)
+
+
+os.path.walk("demos",buildNodes, None)




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to