diff --git a/IPython/html/static/notebook/js/widgets/multicontainer.js b/IPython/html/static/notebook/js/widgets/multicontainer.js index ac9784f..26145d4 100644 --- a/IPython/html/static/notebook/js/widgets/multicontainer.js +++ b/IPython/html/static/notebook/js/widgets/multicontainer.js @@ -11,19 +11,15 @@ require(["notebook/js/widget"], function(){ }, update: function() { - // TODO: Set tab titles + // Set tab titles + var titles = this.model.get('_titles'); + for (var page_index in titles) { + var accordian_toggle = this.containers[page_index] + .find('.accordion-heading') + .find('.accordion-toggle'); + accordian_toggle.html(titles[page_index]); + } - // // Apply flexible box model properties by adding and removing - // // corrosponding CSS classes. - // // Defined in IPython/html/static/base/less/flexbox.less - // var flex_properties = ['vbox', 'hbox', 'center', 'end', 'center']; - // for (var index in flex_properties) { - // if (this.model.get('_' + flex_properties[index])) { - // this.$el.addClass(flex_properties[index]); - // } else { - // this.$el.removeClass(flex_properties[index]); - // } - // } return IPython.WidgetView.prototype.update.call(this); }, @@ -45,7 +41,7 @@ require(["notebook/js/widget"], function(){ .html('Page ' + index) .appendTo(accordion_heading); var accordion_body = $('
', {id: uuid}) - .addClass('accordion-body collapse in') + .addClass('accordion-body collapse') .appendTo(accordion_group); var accordion_inner = $('') .addClass('accordion-inner') diff --git a/IPython/html/widgets/widget_multicontainer.py b/IPython/html/widgets/widget_multicontainer.py index ce16130..3ae16f5 100644 --- a/IPython/html/widgets/widget_multicontainer.py +++ b/IPython/html/widgets/widget_multicontainer.py @@ -15,7 +15,7 @@ pages. # Imports #----------------------------------------------------------------------------- from widget import Widget -from IPython.utils.traitlets import Unicode +from IPython.utils.traitlets import Unicode, Dict #----------------------------------------------------------------------------- # Classes @@ -23,3 +23,33 @@ from IPython.utils.traitlets import Unicode class MulticontainerWidget(Widget): target_name = Unicode('MulticontainerWidgetModel') default_view_name = Unicode('AccordionView') + + # Keys + _keys = ['_titles'] + _titles = Dict(help="Titles of the pages") + + # Public methods + def set_title(self, index, title): + """Sets the title of a container pages + + Parameters + ---------- + index : int + Index of the container page + title : unicode + New title""" + self._titles[index] = title + self.send_state('_titles') + + + def get_title(self, index): + """Gets the title of a container pages + + Parameters + ---------- + index : int + Index of the container page""" + if index in self._titles: + return self._titles[index] + else: + return None