From 60e8ce4a7679a64743d8b0e05e6938e902a03f55 2014-08-08 21:57:51 From: Sylvain Corlay Date: 2014-08-08 21:57:51 Subject: [PATCH] adding hbox and vbox Conflicts: IPython/html/static/widgets/js/widget_container.js IPython/html/widgets/widget_container.py --- diff --git a/IPython/html/static/widgets/js/widget_container.js b/IPython/html/static/widgets/js/widget_container.js index 45f0cc1..9c4889f 100644 --- a/IPython/html/static/widgets/js/widget_container.js +++ b/IPython/html/static/widgets/js/widget_container.js @@ -50,12 +50,23 @@ define([ var FlexContainerView = ContainerView.extend({ render: function(){ FlexContainerView.__super__.render.apply(this); + this.model.on('change:orientation', this.update_orientation, this); this.model.on('change:flex', this._flex_changed, this); this.model.on('change:pack', this._pack_changed, this); this.model.on('change:align', this._align_changed, this); this._flex_changed(); this._pack_changed(); this._align_changed(); + that.update_orientation(); + }, + + update_orientation: function(){ + var orientation = this.model.get("orientation"); + if (orientation == "vertical") { + this.$el.removeClass("hbox").addClass("vbox"); + } else { + this.$el.removeClass("vbox").addClass("hbox"); + } }, _flex_changed: function(){ diff --git a/IPython/html/widgets/__init__.py b/IPython/html/widgets/__init__.py index eb75346..db405fb 100644 --- a/IPython/html/widgets/__init__.py +++ b/IPython/html/widgets/__init__.py @@ -14,7 +14,7 @@ from .interaction import interact, interactive, fixed # Deprecated classes from .widget_bool import CheckboxWidget, ToggleButtonWidget from .widget_button import ButtonWidget -from .widget_container import ContainerWidget, PopupWidget +from .widget_container import ContainerWidget, HBox, VBox, PopupWidget from .widget_float import FloatTextWidget, BoundedFloatTextWidget, FloatSliderWidget, FloatProgressWidget from .widget_image import ImageWidget from .widget_int import IntTextWidget, BoundedIntTextWidget, IntSliderWidget, IntProgressWidget diff --git a/IPython/html/widgets/widget_container.py b/IPython/html/widgets/widget_container.py index adbb1e0..3b02406 100644 --- a/IPython/html/widgets/widget_container.py +++ b/IPython/html/widgets/widget_container.py @@ -37,6 +37,7 @@ class Popup(Container): class FlexContainer(Container): _view_name = Unicode('FlexContainerView', sync=True) + orientation = Unicode('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)