From 2a812710f4750c08d4c336aec2af6e5ef8ad98d2 2014-01-16 10:57:11
From: Jason Grout <jason.grout@drake.edu>
Date: 2014-01-16 10:57:11
Subject: [PATCH] Make sure containers transmit the children; take care of case where children is possibly empty.
---

diff --git a/IPython/html/widgets/widget.py b/IPython/html/widgets/widget.py
index 74bf6c3..b3c949e 100644
--- a/IPython/html/widgets/widget.py
+++ b/IPython/html/widgets/widget.py
@@ -219,7 +219,7 @@ class BaseWidget(LoggingConfigurable):
             # up encoding
             if isinstance(value, BaseWidget):
                 value = value.comm.comm_id
-            elif isinstance(value, list) and isinstance(value[0], BaseWidget):
+            elif isinstance(value, list) and len(value)>0 and isinstance(value[0], BaseWidget):
                 # assume all elements of the list are widgets
                 value = [i.comm.comm_id for i in value]
             state[k] = value
diff --git a/IPython/html/widgets/widget_container.py b/IPython/html/widgets/widget_container.py
index b1528ab..60698c7 100644
--- a/IPython/html/widgets/widget_container.py
+++ b/IPython/html/widgets/widget_container.py
@@ -23,13 +23,14 @@ class ContainerWidget(Widget):
     target_name = Unicode('ContainerWidgetModel')
     default_view_name = Unicode('ContainerView')
 
-    children = [] #List(Instance('IPython.html.widgets.widget.Widget'))
-
     # Keys, all private and managed by helper methods.  Flexible box model
     # classes...
     _keys = ['_vbox', '_hbox', '_align_start', '_align_end', '_align_center',
             '_pack_start', '_pack_end', '_pack_center', '_flex0', '_flex1', 
-            '_flex2', 'description', 'button_text']
+            '_flex2', 'description', 'button_text',
+            'children']
+    children = List(Instance(Widget))
+    
     description = Unicode()
     button_text = Unicode()
     _hbox = Bool(False)
diff --git a/IPython/html/widgets/widget_multicontainer.py b/IPython/html/widgets/widget_multicontainer.py
index 149a6b0..566514d 100644
--- a/IPython/html/widgets/widget_multicontainer.py
+++ b/IPython/html/widgets/widget_multicontainer.py
@@ -25,11 +25,11 @@ class MulticontainerWidget(Widget):
     default_view_name = Unicode('TabView')
 
     # Keys
-    _keys = ['_titles', 'selected_index']
+    _keys = ['_titles', 'selected_index', 'children']
     _titles = Dict(help="Titles of the pages")
     selected_index = Int(0)
 
-    children = [] #List(Instance('IPython.html.widgets.widget.Widget'))
+    children = List(Instance(Widget))
 
     # Public methods
     def set_title(self, index, title):