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')
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 edit_parameters_widget(self): controller = self.controller if controller.ds is None: return pvals_widgets = [FloatText(description=i, value=controller.pvals[i]) for i in sorted(controller.pvals.keys())] wi = VBox(children=pvals_widgets) button = Button(value=False, description="Done") button.on_click(self.update_parameters) button.pvals = pvals_widgets button.wi = wi edit_pvals = VBox(description="Edit Parameters", children=[wi, button]) controller.update_child("Edit Parameters", edit_pvals)
def update_info(self): title = HTML(value='<b> Cases to Co-localize </b>') buttons = [] html_str = '<div><b>Is Valid: {0}</b></div>'.format(self.ci.is_valid()) if self.ci.is_valid() is False: self.make_plot.disabled = True else: self.make_plot.disabled = False valid = HTML(value = html_str) html_str = '<table><caption> Auxiliary variables for ' + self.name html_str += ' with ' + ', '.join(self.slice_variables) html_str += ' as the slice variable{0}.</caption>'.format('s' if len(self.slice_variables) > 1 else '') html_str += '<tr ><th rowspan="2" align=center style="padding:0 15px 0 15px;"> Slice<br> Variables </th>' html_str += '<th colspan="' + str(len(self.cases)) + '" align=center style="padding:0 15px 0 15px;"> Cases </th></tr><tr align=center>' for c in self.cases: html_str += '<td style="padding:0 15px 0 15px;"><b> {0} </b></td>'.format(c.case_number) html_str += '</tr>\n' pset = self.ci.valid_interior_parameter_set() for i in self.cases: key = i.case_number case_button = Button(description='Case ' + key) buttons.append(case_button) case_button.pvals = pset[key] if key in pset else None case_button.on_click(self.open_case) for j, xj in enumerate(self.slice_variables): html_str += '<tr align=center><td>{0}</td>'.format(xj) for i, c in enumerate(self.cases): html_str += '<td>${0}_{1}</td>'.format(xj, i) html_str += '</tr>' html_str += '</table>' html_str += '<caption>Case co-localization assumes that the slice variables ' html_str += 'for one case are independent from the slice variables for the other cases in the co-localization.' html_str += 'Each auxiliary variable corresponds to a slice variable for one cases.</caption>' save_table = Button(description='Save variable table') save_table.on_click(self.save_table) save_table.table_data = html_str variables = HTML(value=html_str) self.info.children = [title] + buttons + [valid, save_table, variables]