def create_checkbox(value): checkbox = widgets.Checkbox(value=value, description='Correct', disabled=False, indent=False, layout=widgets.Layout(width='100px', height='50px', margin='auto')) return checkbox
def _checkBoxMultipleFilters(description, auxiliar): return widgets.Checkbox(description=description, encoding="ascii", width="100%", display='flex', indent=False, style={ "description_width": auxiliar }).add_class('space-checkBox')
def __init__(self, doodle, min_t, max_t, animation_name="morph_triangles"): self.doodle = doodle self.name = animation_name self.min_t = min_t self.max_t = max_t slider = self.slider = widgets.FloatSlider(min=min_t, max=max_t) slider.on_trait_change(self.change_time, "value") checkbox = self.checkbox = widgets.Checkbox(description="animate", value=True) checkbox.on_trait_change(self.change_animation, "value") self.assembly = widgets.VBox(children=[checkbox, doodle.w, slider])
def filter_menu(): input = widgets.Dropdown(description='Input data', options=['Dictionary', 'Pickle', 'Text file'], value='Dictionary') pinfilter = widgets.FloatSlider(min=0.1, max=11, description='Pinned cutoff', value=0.5) ids = widgets.Checkbox(description='Show IDs', value=False) return widgets.VBox([input, pinfilter, ids])
def __init__(self, dynamic_table: DynamicTable, group_by=None, window=None, start_discard_rows=None): """ Parameters ---------- dynamic_table group_by window: None or bool, """ super().__init__(dynamic_table) groups = self.get_groups() self.discard_rows = start_discard_rows self.limit_bit = widgets.BoundedIntText(value=50, min=0, max=99999, disabled=True, layout=Layout(max_width='70px')) self.limit_bit.observe(self.limit_bit_observer) self.limit_cb = widgets.Checkbox(description='limit', style={'description_width': 'initial'}, disabled=True, indent=False, layout=Layout(max_width='70px')) self.limit_cb.observe(self.limit_cb_observer) self.order_dd = widgets.Dropdown(options=[None] + list(groups), description='order by', layout=Layout(max_width='120px'), style={'description_width': 'initial'}) self.order_dd.observe(self.order_dd_observer) self.ascending_dd = widgets.Dropdown(options=['ASC', 'DESC'], disabled=True, layout=Layout(max_width='70px')) self.ascending_dd.observe(self.ascending_dd_observer) range_controller_max = min(30, self.nitems) if window is None: self.range_controller = RangeController(0, self.nitems, start_value=(0, range_controller_max), dtype='int', description='units', orientation='vertical') self.range_controller.observe(self.range_controller_observer) self.window = self.range_controller.value elif window is False: self.window = (0, self.nitems) self.range_controller = widgets.HTML('') self.group_sm = widgets.SelectMultiple(layout=Layout(max_width='100px'), disabled=True, rows=1) self.group_sm.observe(self.group_sm_observer) if group_by is None: self.group_dd = widgets.Dropdown(options=[None] + list(groups), description='group by', style={'description_width': 'initial'}, layout=Layout(width='90%')) self.group_dd.observe(self.group_dd_observer) else: self.group_dd = None self.set_group_by(group_by) self.children = self.get_children() self.layout = Layout(width='280px') self.update_value()
def plot_top_words_with_filters(): global bok_tweets def create_term_document_matrix2(corpus, min_df=1): cvec = CountVectorizer(min_df=min_df, stop_words=stopwords) tfmatrix = cvec.fit_transform(corpus) return pd.DataFrame(data=tfmatrix.toarray(), columns=cvec.get_feature_names()) def plot_top_words_with_filters(num_word_instances, top_words, stop_words, small_words, lower): tweets = bok_tweets.text if lower: tweets = tweets.str.lower() if stop_words: tweets = tweets.apply(remove_stopwords) if small_words: tweets = tweets.str.findall('\w{3,}').str.join(' ') tdm_df = create_term_document_matrix2(tweets, min_df=2) word_frequencies = tdm_df[[x for x in tdm_df.columns if len(x) > 1]].sum() sorted_words = word_frequencies.sort_values(ascending=False) top_sorted_words = sorted_words[:num_word_instances] top_sorted_words[:top_words].plot.bar() return top_sorted_words interact(plot_top_words_with_filters, num_word_instances=widgets.IntSlider(min=1, value=50, continuous_update=False), top_words=widgets.IntSlider(min=1, value=30, continuous_update=False), stop_words=widgets.Checkbox(value=False, description='Filter stop words', continuous_update=False), small_words=widgets.Checkbox(value=False, description='Filter small words', continuous_update=False), lower=widgets.Checkbox(value=False, description='Apply lowercase', continuous_update=False))
def __init__(self): self.all_years_data = self.read_all_years_data() self.expenditure_options = self.build_expenditure_dicts() self.groupby_options = self.build_groupby_dicts() w = interactive(self.make_boxplot, expenditure=widgets.Dropdown(options=self.expenditure_options,value='Total',description='Expenditure category:'), groupby_feature=widgets.Dropdown(options=self.groupby_options,value='Title_1',description='Group schools by feature:'), normalized=widgets.Checkbox(description='Plot expenditure as percent of total:', value=False)) w.border_color = 'red' w.border_style = 'dotted' w.border_width = 3 display(w)
def annotations_widget(): annotations_box = widgets.Checkbox(value=False, description='Use additional ' 'annotations file', disabled=False) annotations_uploader = widgets.FileUpload(accept='xml', multiple=False) annotations_url = widgets.Text(placeholder='Put URL to XML here...', description='Annotation XML file: ', disabled=False) display(annotations_box, annotations_uploader, annotations_url) return annotations_box, (annotations_uploader, annotations_url)
def track_menu(): input = widgets.Dropdown(description='Input data', options=['Dictionary', 'Pickle', 'Text file'], value='Dictionary') max_disp = widgets.FloatSlider(min=0.1, max=11.0, description='Max disp', value=0.5) memory = widgets.IntSlider(description='Memory', min=0, max=5, value=2) predict = widgets.Checkbox(description='Trajectory predictor', value=False) rn1 = widgets.IntSlider(description='Range 1', min=0, max=11, value=3) rn2 = widgets.IntSlider(description='Range 2', min=0, max=11, value=3) return widgets.VBox([input, predict, max_disp, memory, rn1, rn2])
def createPlotsPanel(self): components = self.gluemanager.data.components pixel_component_ids = self.gluemanager.data.pixel_component_ids world_component_ids = self.gluemanager.data.world_component_ids v = [] for k in components: if k not in world_component_ids: #k not in pixel_component_ids and kt = str(k) vv = widgets.ToggleButton( value=False, tooltip=kt, description=kt ) v.append(vv) tb = widgets.HBox(v) cr = widgets.Button( description='Create new visualization', disabled=False, button_style='', tooltip='', ) views = self.gluemanager.listPlots() dd = widgets.Dropdown( options=views, value=views[0], disabled=False, ) ss = widgets.Checkbox( value=False, description='Only subsets', disabled=False ) tx = widgets.Text( value='', placeholder='New_Visualization', disabled=False ) hb1 = widgets.HBox([dd,tx,ss,cr]) vb1 = widgets.VBox([tb,hb1]) from IPython.display import display cr.on_click(lambda e : GlueManagerWidget.createNewView(self,e, dd, tb.children, tx, ss)) return vb1
def __init__(self, on_true=None, on_false=None, on_true_output=None, on_false_output=None, \ on_true_overwrite_previous_output=True, on_false_overwrite_previous_output=True, on_true_feedback=False, \ on_false_feedback=False, run=True, layout={'width':'max-content'}, indent=False, on_true_action_kws={}, on_false_action_kws={}, *args, **kwargs): super().__init__(on_true=on_true, on_false=on_false, on_true_output=on_true_output, on_true_action_kws=on_true_action_kws, on_false_output=on_false_output, \ on_true_overwrite_previous_output=on_true_overwrite_previous_output, on_false_overwrite_previous_output=on_false_overwrite_previous_output, on_true_feedback=on_true_feedback, \ on_false_feedback=on_false_feedback, on_false_action_kws=on_false_action_kws) self.widget = widgets.Checkbox(layout=layout, indent=indent, *args, **kwargs) if run: self.run()
def __init__(self, network, parent, *args, **kwargs): super(NetworkHolder, self).__init__(*args, **kwargs) self.network = network self.parent = parent network.maximize = False mcb = self.maximize_cb = widgets.Checkbox(description=u"\u22EF", tooltip="maximize", value=False) db = self.diff_button = self.make_button(u"\u2296", self.diff_all, "difference with all") ib = self.int_button = self.make_button(u"\u2227", self.intersect_all, "intersect all") sb = self.sync_button = self.make_button(u"\u22A8", self.sync_all, "sync all") self.width_slider = s = widgets.IntSlider(value=200, min=100, max=2000, step=10, readout=False, width="150px") s.layout.width = "150px" self.make_linkages() buttons = widgets.HBox(children=[db, ib, sb, s, mcb]) self.assembly = widgets.VBox(children=[buttons, network.assembly])
def on_add_tag(evt, box, options, new_tag, all_checkboxes): if new_tag.value in options: return elif new_tag.value.strip() == '': returnpath2database = path2database else: options.append(new_tag.value) newcb = widgets.Checkbox(description=new_tag.value) newcb.observe(on_cb_change, names=['_property_lock']) all_checkboxes.append(newcb) box_child_list = list(box.children + (newcb, )) box_child_list.sort(key=lambda x: x.description) box.children = box_child_list self.controller.tp_box = box return
def instantiate_objects(self): self.out_graph = widgets.Output() self.out_url = widgets.Output() self.out_func = widgets.Output() self.btn_gen = widgets.Button(description="Generate Vis") self.btn_add = widgets.Button(description="Add Mapping") self.btn_rem = widgets.Button(description="Remove Mapping") self.btn_clear_assigned = widgets.Button(description="Clear") self.sel_cols = widgets.Select(options=[], disabled=False) self.sel_fields = widgets.Select(options=[], disabled=False) self.sel_assigned = widgets.Select(options=[], disabled=False) self.lbl_cols = widgets.Label(value="Columns") self.chk_incidx = widgets.Checkbox(value=False, description='Inc. Index', disabled=False, indent=False) self.lbl_fields = widgets.Label(value="Fields") self.lbl_assigned = widgets.Label(value="Assigned") self.lbl_core = widgets.Label(value="Visualization Core") self.lbl_title = widgets.Label(value="Chart Title:") self.txt_title = widgets.Text(value="My Chart") self.txt_xaxis = widgets.Text(value="") self.txt_yaxis = widgets.Text(value="") self.lbl_xaxis = widgets.Label(value="X Axis") self.lbl_yaxis = widgets.Label(value="Y Axis") self.lbl_charth = widgets.Label(value="Chart Height:") self.lbl_chartw = widgets.Label(value="Chart Width:") self.txt_charth = widgets.Text(value="750") self.txt_chartw = widgets.Text(value="2000") self.lbl_break = widgets.Label( value= "---------------------------------------------------------------------------------" ) self.sel_df = widgets.Select(options=[], description='Data Frame:', disabled=False) self.drp_charts = widgets.Dropdown(options=[], description='Chart Type:', disabled=False)
def __init__(self, Notebook): super(Plot_Pareto_Fronts, self).__init__(Notebook) self.notebook.dependencies_dict["seed"].append(self) self.widget_selectGenerations = widgets.SelectMultiple( options=[None], value=[None], description='Generation', disabled=True) self.widget_selectText = widgets.Text( value="", placeholder="List of generations separated with commas.", disabled=True) self.widget_plot = widgets.Button(description="Plot Pareto Fronts", disabled=True) self._widget_with_indexes = widgets.Checkbox( value=False, description='Display indexes', disabled=False)
def view( start_date=widgets.DatePicker(value=pd.to_datetime(stime)), end_date=widgets.DatePicker(value=pd.to_datetime(etime)), debug=widgets.Checkbox(value=False)): duration = (pd.to_datetime(start_date), pd.to_datetime(end_date)) duration2 = (pd.to_datetime(start_date), pd.to_datetime(start_date) + pd.DateOffset(days=7)) real_events = vs.filterTime(evalres[fold]['test'].real_events, duration) pred_events = vs.filterTime(evalres[fold]['test'].pred_events, duration) #vs.plotJoinAct(dataset,real_events,pred_events) acts = [p for p in dataset.activities_map] labels = [dataset.activities_map[p] for p in acts] print(acts) print(labels) vs.plotJoinAct2(real_events, pred_events, acts, labels, duration=duration2) #vs.plot_per_act(dataset,{'test':evalres}) from matplotlib import pyplot as plt plt.rc_context(rc={'figure.max_open_warning': 0}) acount = len(dataset.activities_map) for i in range(1, len(dataset.activities_map)): # real_events2,pred_events2=vs.remove_gaps(real_events,pred_events,i) #real_events2,pred_events2=vs.remove_gaps(real_events,pred_events,i,max_events=10) real_events2, pred_events2 = real_events, pred_events # vs.plotJoinAct(dataset,real_events,pred_events,onlyAct=i,ax=a_ax[i-1]) try: # vs.plotJoinAct(dataset,real_events2,pred_events2,onlyAct=i,ax=a_ax[i-1]) vs.plotWardMetric(dataset, real_events, pred_events, onlyAct=i) except Exception as e: import sys import traceback print(e, file=sys.stderr) traceback.print_exc()
def _build_strat_form(self): label_width = '20rem' control_width = '35rem' ap_label = widgets.Label('Aperture radius:') ap_label.layout.width = label_width self.ap_size = widgets.FloatSlider( value=0.1, min=self.APERTURE_MIN, max=self.APERTURE_MAX, step=self.APERTURE_INCREMENT, ) self.ap_size.layout.width = control_width self.ap_size.observe(self.check_ann, names='value') self.overplot = widgets.Checkbox(description="Overlay apertures?", value=True) self.overplot.observe(self._trigger_update_plots, names='value') extraction_aperture = widgets.HBox([ ap_label, self.ap_size, widgets.Label('arcsec'), ]) background_annulus_label = widgets.Label("Background annulus radii:") background_annulus_label.layout.width = label_width self.background_annulus = widgets.FloatRangeSlider( value=[self.ap_size.value + 0.1, self.ap_size.value + 0.2], min=0, max=2.0, step=self.APERTURE_INCREMENT, ) self.background_annulus.layout.width = control_width self.background_annulus.observe(self.check_ann, 'value') background_estimation = widgets.HBox([ background_annulus_label, self.background_annulus, widgets.Label("arcsec"), ]) background_estimation.layout.width = '100%' return widgets.VBox([ extraction_aperture, background_estimation, self.overplot ])
def custom_with_checkbox(self, description, condition): item_index = len(self._checklist) def toggle_cb(change): val = change['new'] msg = "Not OK" if val == True: msg = "OK" self._checklist[item_index]['result'] = msg self.append_custom_item(description, condition, "", "Not OK") l = widgets.Label(description, layout=Layout(width='75%')) cb = widgets.Checkbox(value=False, description="OK?", layout=Layout(width='25%')) cb.observe(toggle_cb, names='value') item = widgets.HBox([l, cb]) display(item)
def appendPVWidgets (pv = ""): PVNameWidget = widgets.Text (description = "PV Name:", value = pv) PVBinsWidget = widgets.Checkbox(value = False, description = 'Optimized?') PVBinsIntWidget = widgets.IntText (value = "500", description = "# bins:", disabled = not PVBinsWidget.value) PVRemoveWidget = widgets.Button (description = "Remove") PVBinsWidget.observe (updateBinsText) PVRemoveWidget.on_click(removePVHandler) newRow = widgets.HBox ([PVNameWidget, PVBinsWidget, PVBinsIntWidget, PVRemoveWidget]) PVRemoveWidget.parent = newRow PVBinsWidget.parent = newRow PVWidgetList.append (newRow) appendPVVBox.children = PVWidgetList + [appendPVWidget]
def plot_forces(self, mean=100): # Need to disable autoscroll # autoscroll(-1) self.rolling_avg = mean if self.header_list is None: return if self.cb_container is None: self.out = widgets.Output() self.checkboxes = [] self.cb_container = widgets.VBox() for h in self.header_list: if h not in self.residual_list and h not in [ "RealTimeStep", "Cycle" ]: self.checkboxes.append( widgets.Checkbox(description=h, value=False, width=90)) row_list = [] for i in range(0, len(self.checkboxes), 3): row = widgets.HBox() row.children = self.checkboxes[i:i + 3] row_list.append(row) self.cb_container.children = [i for i in row_list] self.rolling = widgets.IntSlider( value=self.rolling_avg, min=1, max=1000, step=1, description="Rolling Average:", ) self.button = widgets.Button(description="Update plots") self.button.on_click(self.plot_data) display(self.out) display(self.cb_container) display(self.rolling) display(self.button)
def load_datalayers(self): """Load exisiting datalayers into widget""" self.filenames = list_datalayers() for filename in self.filenames: self.checkbox_dict[filename] = widgets.Checkbox( vaue=False, indent=False, layout=LAYOUT_CHECKBOX ) self.checkbox_dict[filename].observe(self.checkbox_change_listener, names='value') self.label_dict[filename] = widgets.Label( f'{filename}', layout=LAYOUT_CHECKBOX_LABEL ) self.checkbox_boxes.children = list(self.checkbox_dict.values()) self.checkbox_labels.children = list(self.label_dict.values())
def plot_test(self, report_file): self.resildual_checkboxes = [] cb_container = widgets.VBox() display(cb_container) for h in self.header_list: if h not in self.residual_list and h not in [ 'RealTimeStep', 'Cycle' ]: self.checkboxes.append( widgets.Checkbox(description=h, value=False, width=90)) row_list = [] for i in range(0, len(self.checkboxes), 3): row = widgets.HBox() row.children = self.checkboxes[i:i + 3] row_list.append(row) cb_container.children = [i for i in row_list]
def search_available_images(self): out_file = widgets.Checkbox( value=False, description="Save results of search to file?", disabled=False, indent=False, ) button = widgets.Button(description="Search catalog!") def search_catalog(): assert self.ensure_variables( (self.catalog, self.search_parameters, self.aoi, self.outdir) ), "Please run steps before (authenticate, select AOI, select output dir and create search parameters)!" search_results = self.catalog.search( search_parameters=self.search_parameters, as_dataframe=True) assert (not search_results.empty ), "No results found! Try other search parameters." search_results["incidenceAngle"] = search_results[ "providerProperties"].apply(lambda x: x["incidenceAngle"]) display(search_results) self.catalog.plot_coverage(scenes=search_results, aoi=self.aoi) # Reduce columns & export df = search_results[[ "geometry", "id", "sceneId", "cloudCoverage", "blockNames", "incidenceAngle", ]].copy() df["blockNames"] = df["blockNames"].astype(str) if out_file.value: df.to_file( driver="GeoJSON", filename=self.outdir / "search_results_limited_columns.geojson", ) self.search_results = search_results self.search_results_df = df self.process_template([out_file], button, search_catalog)
def __init__(self, n_rules, avail_records, refresh_ptcl): """ Initialize a set of particle selection widgets Parameters: ----------- n_rules: int The number of selection rules to display avail_records: list of strings The list of available records for the current species refresh_ptcl: callable The callback function to execute when the widget is changed """ self.n_rules = n_rules # Create widgets that determines whether the rule is used self.active = [widgets.Checkbox(value=False) for i in range(n_rules)] # Create widgets that determines the quantity on which to select # (The Dropdown menu is empty, but is later populated by the # function refresh_species) self.quantity = [ widgets.Dropdown(options=avail_records, description='Select ') for i in range(n_rules) ] # Create widgets that determines the lower bound and upper bound self.low_bound = [ widgets.FloatText(value=-1.e-1, description='from ') for i in range(n_rules) ] self.up_bound = [ widgets.FloatText(value=1.e-1, description='to ') for i in range(n_rules) ] # Add the callback function refresh_ptcl to each widget for i in range(n_rules): self.active[i].observe(refresh_ptcl, 'value', 'change') self.quantity[i].observe(refresh_ptcl, 'value', 'change') self.low_bound[i].observe(refresh_ptcl, 'value', 'change') self.up_bound[i].observe(refresh_ptcl, 'value', 'change')
def __init__(self, n_rules, avail_ptcl_quantities, refresh_ptcl): """ Initialize a set of particle selection widgets Parameters: ----------- n_rules: int The number of selection rules to display avail_ptcl_quantities: list of string The particle quantities in the present openPMD timeseries refresh_ptcl: callable The callback function to execute when the widget is changed """ self.n_rules = n_rules # Create widgets that determines whether the rule is used self.active = [ widgets.Checkbox(value=False) \ for i in range(n_rules) ] # Create widgets that determines the quantity on which to select self.quantity = [ widgets.Dropdown(options=avail_ptcl_quantities, description='Select ') for i in range(n_rules) ] # Create widgets that determines the lower bound and upper bound self.low_bound = [ widgets.FloatText(value=-1.e-1, width=90, description='from ') for i in range(n_rules) ] self.up_bound = [ widgets.FloatText(value=1.e-1, width=90, description='to ') for i in range(n_rules) ] # Add the callback function refresh_ptcl to each widget for i in range(n_rules): self.active[i].on_trait_change(refresh_ptcl) self.quantity[i].on_trait_change(refresh_ptcl) self.low_bound[i].on_trait_change(refresh_ptcl) self.up_bound[i].on_trait_change(refresh_ptcl)
def produced_by_country(): global year, allyear, df, fig conn = sqlite3.connect("data/movies.db") df = pd.read_sql_query( "Select * from Country c Join Location l on (c.country_id = l.id)", conn) # df.dropna(axis='rows',inplace=True) df['e'] = df.iloc[:, 2:31].sum(axis=1) conn.close() year = widgets.IntSlider(value=1.0, min=1989, max=2017, step=1.0, description='Year:', continuous_update=False) allyear = widgets.Checkbox( description='1989 - 2017', value=False, ) container = widgets.HBox(children=[allyear, year]) fig = go.FigureWidget( go.Choropleth(locations=df['iso_3'], z=df.N1989, colorscale='oranges', autocolorscale=False, marker_line_color='darkgray', marker_line_width=0.5, colorbar_title='Number of movies')) fig.update_layout(title_text='Number of Produced Movies', geo=dict(showframe=False, showcoastlines=False, projection_type='equirectangular')) year.observe(response, names="value") allyear.observe(response, names="value") return widgets.VBox([container, fig])
def create_qubit_and_plot_choice_widgets(self): """Creates all the widgets that controls which qubit or plot the user can choose from. """ self.qubit_and_plot_choice_widgets = { "qubit_buttons": widgets.ToggleButtons( options=self.supported_qubits, description="Qubits:", layout=widgets.Layout(width="800px"), ), "plot_buttons": widgets.ToggleButtons( options=self.plot_choices, description="Plot:", button_style="info", ), "show_qubitinfo_checkbox": widgets.Checkbox( value=False, description="qubit info", disabled=False ), } self.qubit_and_plot_choice_widgets["qubit_buttons"].observe( self.qubit_buttons_eventhandler, names="value" )
def FourierSeries(): """ Main function called by notebook """ terms_sldr = widgets.IntSlider(value=3, description='Terms', min=2, max=100, display=False, continuous_update=False) func_drp = widgets.Dropdown(options=['Linear', 'Square Wave', 'Cubic'], description='Function') prevTerm_check = widgets.Checkbox(value=False, description='Show most recent term') return widgets.VBox([ widgets.HBox([terms_sldr, func_drp, prevTerm_check]), widgets.interactive_output( fourierMain, { 'function': func_drp, 'nMax': terms_sldr, 'showPrevTerm': prevTerm_check }) ])
def wofost_parameter_sweep(): widgets.interact_manual( wofost_parameter_sweep_func, crop_start_date=widgets.fixed(dt.date(2011, 7, 1)), crop_end_date=widgets.fixed(dt.date(2011, 11, 1)), span=widgets.FloatSlider(value=40.0, min=20, max=50), cvo=widgets.FloatSlider(value=0.72, min=0.1, max=0.9, step=0.02), cvl=widgets.FloatSlider(value=0.72, min=0.1, max=0.9, step=0.02), tdwi=widgets.FloatSlider(value=20.0, min=5, max=50), tsum1=widgets.FloatSlider(value=750.0, min=100, max=1500), tsum2=widgets.FloatSlider(value=859.0, min=100, max=1500), tsumem=widgets.FloatSlider(value=70, min=10, max=200), rgrlai=widgets.FloatSlider(value=0.05, min=0.001, max=0.3, step=0.01), meteo=widgets.fixed("Upper_East"), crop=widgets.fixed("maize"), variety=widgets.fixed("Maize_VanHeemst_1988"), soil=widgets.fixed("ec4.new"), wav=widgets.FloatSlider(value=5, min=0, max=100), co2=widgets.fixed(400), rdmsol=widgets.fixed(100.), potential=widgets.Checkbox(value=False, description='Potential mode', icon='check'))
def on_add_tag_new(evt, box, options, all_checkboxes, all_values): if evt.value in options: return elif evt.value.strip() == '': return else: options.append(evt.value) newcb = widgets.Checkbox(description=evt.value, indent=False, value=False) newcb.observe( lambda x: on_cb_change(x, all_checkboxes, all_values), names=['_property_lock']) newtext = widgets.Text(placeholder=evt.value) newtext.on_submit( lambda x: on_cb_change(x, all_checkboxes, all_values)) newbox = widgets.HBox([newcb, newtext]) all_checkboxes.append(newcb) all_values.append(newtext) box_child_list = list(box.children + (newbox, )) # box_child_list.sort(key=lambda x: x.children[0].description) box.children = box_child_list self.controller.tp_box = box return