def save_figure_widget(self, image_data, title='', caption = '', pvals=None, colors=None):
     image_widget = Image()
     image_widget.value = image_data
     children = [i for i in self.figures_widget.children]      
     html_str = '<b>Figure '+str(len(children)+1)+'.  '+title+'</b>' + caption
     html_widget = HTML(value=html_str)
     restore_pvals = Button(description='Restore Parameter Values')
     restore_pvals.pvals = pvals
     if pvals is None:
         restore_pvals.visible = False
     if old_ipython is True:
         image_widget = Image()
         image_widget.value = image_data
         tab_widget = VBox(children=[image_widget, html_widget])
         if colors is not None:
             html_widgets = self.colorbar_tabs(colors)
             tab_widget.description='Figure'
             tab_widget = Tab(children=[tab_widget]+html_widgets)
     else:
         image_widget = self._image_widget_new(image_data, colors=colors)
         tab_widget = VBox(children=[image_widget, html_widget])
     restore_pvals.on_click(self.restore_figure_pvals)
     if old_ipython is True:
         wi = Popup(children=[tab_widget, restore_pvals])
     else:
         contents = VBox(children=[tab_widget, restore_pvals])
         contents.width = '100%'
         wi = Popup(children=[contents])
         wi.border = '1px solid black'
     children.append(wi)
     self.figures_widget.children = children
     if colors is not None:
         if old_ipython is True:
             tab_widget.set_title(0, 'Figure')
             tab_widget.set_title(1, 'Colorbar')
 def add_figure_widget(self, image_data, title='', caption = '', pvals=None, colors=None):
     children = [i for i in self.unsaved.children]      
     if len(title) > 0:
         title = title + '.'
     if len(caption) > 0:
         caption = '  ' + caption
     html_str = '<b>'+title+'</b>' + caption
     html_widget = HTML(value=html_str)
     save_button = Button(description='Save Figure')
     save_button.image_data = image_data
     save_button.title = title
     save_button.caption = caption
     save_button.on_click(self.save_unsaved_figure)
     save_button.pvals = pvals
     save_button.colors = colors
     close_button = Button(description='Remove Figure')
     close_button.on_click(self.remove_unsaved_figure)
     restore_pvals = Button(description='Restore Parameter Values')
     restore_pvals.pvals = pvals
     if pvals is None:
         restore_pvals.visible = False
     if old_ipython is True:
         image_widget = Image()
         image_widget.value = image_data
         tab_widget = VBox(children=[image_widget, html_widget])
         if colors is not None:
             html_widgets = self.colorbar_tabs(colors)
             tab_widget.description='Figure'
             tab_widget = Tab(children=[tab_widget]+html_widgets)
     else:
         image_widget = self._image_widget_new(image_data, colors=colors)
         tab_widget = VBox(children=[image_widget, html_widget])
         toggle = Button(description='Hide')
         
     restore_pvals.on_click(self.restore_figure_pvals)
     if old_ipython is True:
         wi = Popup(children=[close_button, save_button, tab_widget, restore_pvals])
     else:
         contents = VBox(children=[close_button, save_button, tab_widget, restore_pvals])
         contents.width = '100%'
         wi = Popup(children=[contents])
         wi.border = '1px solid black'
     save_button.wi = wi
     close_button.wi = wi
     children.append(wi)
     self.unsaved.children = children
     if colors is not None:
         if old_ipython is True:
             tab_widget.set_title(0, 'Figure')
             tab_widget.set_title(1, 'Colorbar')