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 make_interactive_plot(self, b):
     controller = self.controller
     if str(b.ylabel.value) == 'None':
         return
     button = Button(description='Stop interactive plot')
     button.on_click(self.remove_plot)
     button.name = 'Interactive Plot (' + str(np.random.randint(0, 1000)) + ')'
     image_widget = Image()
     popup_widget = Popup(children=[image_widget])
     image_widget.width='100%'
     rangex, rangey = self.axes_ranges(b)
     interactive_plot = controller.ds.draw_2D_slice_notebook(controller.pvals, str(b.xlabel.value),
                                                             str(b.ylabel.value),
                                                             rangex, rangey,
                                                             {i:[1e-5, 1e5] for i in
                                                              controller.pvals},
                                                             intersections=[1],
                                                             image_container=image_widget)
     wi = VBox(description=button.name,
                                  children=[interactive_plot, 
                                            button,
                                            popup_widget])
     controller.options.update({'xaxis':str(b.xlabel.value),
                                'yaxis':str(b.ylabel.value),
                                'x_range':rangex, 
                                'y_range':rangey})
     controller.update_child(button.name, wi)
 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')