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')
def create_case_widget(self): controller = self.controller if controller.ds is None: return case = self.case self.info = VBox() self.equations = VBox() self.log_gains = VBox() self.parameter_table = VBox() self.tolerances_table = VBox() self.bounding_box_table = VBox() calculate_pvals = Button(description='Determine values for the parameters') calculate_pvals.visible = False calculate_pvals.on_click(self.identify_parameters) if case.is_valid() is True and case.is_cyclical is False: if self.pvals is None: calculate_pvals.visible = True close_button = Button(description='Close Tab') close_button.on_click(self.close_widget) wi = Popup(children=[self.info, self.equations, self.log_gains, self.bounding_box_table, calculate_pvals, self.parameter_table, self.tolerances_table, close_button]) if ipy_old is True: wi.set_css('height', '400px') else: wi.width = '700px' self.update_display() subtitle = self.subtitle if subtitle != '': subtitle = ' (' + subtitle + ')' self.title = 'Case ' + self.case.case_number + subtitle controller.update_child(self.title, wi)
def edit_equations_widget(self, editing=False): kinetic_orders = self.options['kinetic_orders'] if kinetic_orders is None: kinetic_orders = [] name = Text(description='* Name', value=self.name) version = Text(description='Version', value=self.version) self.version_field = version equations=Textarea(description='* Equations', value='\n'.join(self.equations)) aux=Textarea(description='Auxiliary Variables', value=', '.join(self.auxiliary)) html = HTML(value='<b>Architectural Constraints</b>') constraints=Textarea(description='Parameters', value=', '.join(self.constraints) ) options_html = HTML(value='<b>Additional Options</b>') cyclical = Checkbox(description='Check for Cycles', value = self.cyclical) codominance = Checkbox(description='Check for Co-dominance', value = self.codominance) recast = Checkbox(description='Recast Equations', value = self.recast) replacements=Textarea(description='Kinetic Orders', value=', '.join( [i for i in kinetic_orders])) wi = VBox(children=[equations, aux, html, constraints, replacements, options_html, cyclical, codominance,recast, ]) button = Button(value=False, description='Create Design Space') button.on_click(self.make_design_space) button.equations = equations button.aux = aux button.constraints = constraints button.cyclical = cyclical button.codominance = codominance button.recast = recast button.replacements = replacements button.wi = wi button.name = name ## button.version = version load = Button(value=False, description='Load Data') load.on_click(self.load_widget) load.equations = equations ## load.version = version load.aux = aux load.constraints = constraints load.cyclical = cyclical load.codominance = codominance load.replacements = replacements load.wi = wi load.name = name load.button = button button.load = load edit_symbols = Button(value=False, description='Edit Symbols') edit_symbols.on_click(self.create_edit_symbols) edit_parameters = Button(value=False, description='Edit Parameters') edit_parameters.on_click(self.create_edit_parameters) button.edit_symbols = edit_symbols button.edit_parameters = edit_parameters edit_equations = VBox(description='Edit Equations', children=[name, version, wi, edit_symbols, edit_parameters, button, load]) wi.visible = False edit_symbols.visible = False edit_parameters.visible = False if self.ds is not None: wi.visible = True ## self.update_widgets() self.make_options_menu(button) if editing is True: self.make_design_space(button) return edit_equations