adding hbox and vbox

Conflicts:
	IPython/html/static/widgets/js/widget_container.js
	IPython/html/widgets/widget_container.py
This commit is contained in:
Sylvain Corlay 2014-07-17 20:53:20 +00:00 committed by Jonathan Frederic
parent 170b13102e
commit c9ed512d54
3 changed files with 13 additions and 1 deletions

View File

@ -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(){

View File

@ -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

View File

@ -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)