From dbb88f95cd1d6ffebad7e1e2cde4ef9b13ef3e48 Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Fri, 18 Jul 2014 14:34:39 -0700 Subject: [PATCH] Make HBox and VBox helper functions --- IPython/html/widgets/widget_container.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/IPython/html/widgets/widget_container.py b/IPython/html/widgets/widget_container.py index 3b0240652..1438da69c 100644 --- a/IPython/html/widgets/widget_container.py +++ b/IPython/html/widgets/widget_container.py @@ -37,7 +37,7 @@ class Popup(Container): class FlexContainer(Container): _view_name = Unicode('FlexContainerView', sync=True) - orientation = Unicode('vertical', sync=True) + orientation = CaselessStrEnum(values=['vertical', 'horizontal'], default_value='vertical', sync=True) flex = Int(0, sync=True, help="""Specify the flexible-ness of the model.""") def _flex_changed(self, name, old, new): new = min(max(0, new), 2) @@ -53,12 +53,14 @@ class FlexContainer(Container): default_value='start', allow_none=False, sync=True) -class VBox(FlexContainer): - _view_name = Unicode('VBoxContainerView', sync=True) +def VBox(*pargs, **kwargs): + kwargs['orientation'] = 'vertical' + return FlexContainer(*pargs, **kwargs) +def HBox(*pargs, **kwargs): + kwargs['orientation'] = 'horizontal' + return FlexContainer(*pargs, **kwargs) -class HBox(FlexContainer): - _view_name = Unicode('HBoxContainerView', sync=True) ContainerWidget = DeprecatedClass(Container, 'ContainerWidget') PopupWidget = DeprecatedClass(Popup, 'PopupWidget')