Commits

paj  committed 2ddd579

Add TreeView

  • Participants
  • Parent commits 90f3e8c

Comments (0)

Files changed (4)

File examples/test.py

 import tw2.core as twc, tw2.forms as twf, tw2.yui as twy
 
+opts = [
+    'Paj',
+    {'label': 'blah', 'children': ['a', 'b', 'c']},
+    'Joe',
+]
+
 class Index(twf.FormPage):
     title = 'YUI Test'
     attrs = {'class':'yui-skin-sam'}
     class child(twf.Form):
         class child(twf.TableLayout):
             check = twf.CheckBox(validator=twc.Required)
-            color = twy.Editor()
+            color = twy.TreeView(options=opts)
 
 if __name__ == '__main__':
     import wsgiref.simple_server as wrs

File tw2/yui/__init__.py

 from widgets import (Slider, TabView, AutoComplete, ColorPicker, Calendar,
-        Editor)
-
-
-
+        Editor, TreeView)

File tw2/yui/templates/treeview.html

+<div>
+
+<div id="$w.compound_id">
+</div>
+
+<script type="text/javascript">
+    YAHOO.util.Event.onDOMReady(function() {
+        tree = new YAHOO.widget.TreeView("$w.compound_id", $w.options);
+        tree.render();
+    });
+</script>
+
+</div>

File tw2/yui/widgets.py

     def prepare(self):
         super(Editor, self).prepare()
         self.config = encoder.encode(self.config)
+
+
+class TreeView(twc.Widget):
+    resources = [
+        twc.DirLink(modname=__name__, filename="static/2.7.0/"),
+        twc.CSSLink(modname=__name__, filename="static/2.7.0/fonts/fonts-min.css"),
+        twc.CSSLink(modname=__name__, filename="static/2.7.0/treeview/assets/skins/sam/treeview.css"),
+        twc.JSLink(modname=__name__, filename="static/2.7.0/yahoo-dom-event/yahoo-dom-event.js"),
+        twc.JSLink(modname=__name__, filename="static/2.7.0/treeview/treeview-min.js"),
+    ]
+    template = "genshi:tw2.yui.templates.treeview"
+
+    options = twc.Param('tree options', default=[])
+
+    def prepare(self):
+        super(TreeView, self).prepare()
+        self.options = encoder.encode(self.options)