def init_panelleft(self): self.ui_title = iwg.HTML("<h2>Drag the marker to your region of interest</h2>") self.idxs = self.spatial_index.query_pathrow(self.query_pt) self.prlist = [('{:03d}/{:03d}'.format(self.spatial_index.footprint.loc[i, 'path'], self.spatial_index.footprint.loc[i, 'row']) ,i) for i in self.idxs] self.menuleft = iwg.Select(options=self.prlist, description='Path/Row:', rows=15) self.kernelselection = iwg.RadioButtons(options=['ITS_LIVE (online ready)', 'CARST'], value='ITS_LIVE (online ready)', description='Data / Kernel:') self.datesearch_btn = iwg.Button(description='Search for dates')
def __init__( self, description: str = "Select an item", item_list: List[str] = None, action: Callable[..., None] = None, item_dict: Mapping[str, str] = None, auto_display: bool = False, height: str = "100px", width: str = "50%", ): """ Select an item from a list or dict. Parameters ---------- description : str, optional The widget label to display. (the default is 'Select an item') item_list : List[str], optional A `list` of items to select from (the default is None) item_dict : Mapping[str, str], optional A `dict` of items to select from. When using `item_dict` the keys are displayed as the selectable items and value corresponding to the selected key is set as the `value` property. (the default is None) action : Callable[..., None], optional function to call when item selected (passed a single parameter - the value of the currently selected item) (the default is None) auto_display : bool, optional Whether to display on instantiation (the default is False) height : str, optional Selection list height (the default is '100px') width : str, optional Selection list width (the default is '50%') """ if item_list: self._item_list = item_list self._item_dict = None self.value = item_list[0] elif item_dict: self._item_list = list(item_dict.keys()) self._item_dict = item_dict self.value = list(self._item_dict.values())[0] else: raise ValueError("One of item_list or item_dict must be supplied.") self.item_action = action self._wgt_select = widgets.Select( options=self._item_list, description=description, layout=Layout(width=width, height=height), style={"description_width": "initial"}, ) self._wgt_select.observe(self._select_item, names="value") if auto_display: self.display()
def __init__(self, name): self.dirname = os.path.join(name, "") odtfile = max(glob.iglob("{}*.odt".format(self.dirname)), key=os.path.getctime) self.dt = oommfodt.OOMMFodt(odtfile).df self.time = self.dt["t"].as_matrix() / 1e-12 self.slider = ipywidgets.IntSlider( value=self.time[0], min=self.time[0], max=self.time[-1], step=self.time[1] - self.time[0], description="t (ps):", readout=True, layout=ipywidgets.Layout(width="100%"), continuous_update=False) self.select = ipywidgets.Select(options=list(self.dt.columns.values), description="Output:") self.play = ipywidgets.Play(value=self.time[0], min=self.time[0], max=self.time[-1], step=self.time[1] - self.time[0]) ipywidgets.jslink((self.play, "value"), (self.slider, "value")) self.slider.observe(self.update_output_slider) self.select.observe(self.update_output_slider) self.out = ipywidgets.Output(layout=ipywidgets.Layout(width="300%")) self.update_output_slider(None)
def _ipython_display_(self): import ipywidgets from IPython.display import display, Markdown names = dir(self) names.sort() def change_field(_ftype, _box, _var_window): def _change_field(event): fobj = getattr(_ftype, event['new']) _box.clear_output() with _box: display(Markdown(data = "```python\n" + textwrap.dedent(fobj.get_source()) + "\n```")) values = inspect.getclosurevars(fobj._function).nonlocals _var_window.value = _fill_values(values) return _change_field flist = ipywidgets.Select(options = names, layout = ipywidgets.Layout(height = '95%')) source = ipywidgets.Output(layout = ipywidgets.Layout( width = '100%', height = '9em')) var_window = ipywidgets.HTML(value = 'Empty') var_box = ipywidgets.Box(layout = ipywidgets.Layout( width = '100%', height = '100%', overflow_y = 'scroll')) var_box.children = [var_window] ftype_tabs = ipywidgets.Tab(children = [source, var_box], layout = ipywidgets.Layout(flex = '2 1 auto', width = 'auto', height = '95%')) ftype_tabs.set_title(0, "Source") ftype_tabs.set_title(1, "Variables") flist.observe(change_field(self, source, var_window), "value") display(ipywidgets.HBox([flist, ftype_tabs], layout = ipywidgets.Layout(height = '14em')))
def widget(self): pbox = [] # ファイル名とファイル内容 self.iName_w = widgets.Text(description="入力ファイル", value="", layout=Layout(width='100%'), disabled=False) self.iText_w = widgets.Textarea(value="", rows=5, layout=Layout(width='100%'), disabled=True) pbox.append(self.iName_w) pbox.append(self.iText_w) self.oPath_w = widgets.Text(description="出力パス", value="", layout=Layout(width='100%'), disabled=False) pbox.append(self.oPath_w) self.oFile_w = widgets.Text(description="ファイル名", value="", layout=Layout(width='100%'), disabled=False) pbox.append(self.oFile_w) self.titles_w = widgets.Select(options=[], description="歌詞の選択", rows=10, layout=Layout(width='100%')) pbox.append(self.titles_w) box = widgets.VBox(pbox) return box
def _build_concept_list(self): def concept_list_watcher(change): x = change.get('new') if x: node = self.api.tree_dict.get(x) metadata = dict(node.get('metadata', {})) d = { 'path': node.get('conceptPath'), 'type_': node.get('type'), 'study_id': node.get('studyId'), 'name': node.get('name'), 'metadata': '<br> '.join(['{}: {}'.format(k, v) for k, v in metadata.items()]) } self.result_text.value = self.table_template.format(**d) concept_list = ipywidgets.Select( options=self.list_of_default_options[:MAX_OPTIONS], rows=10, disabled=False, continous_update=False, layout={'width': '50%'} ) concept_list.observe(concept_list_watcher, 'value') return concept_list
def __init__(self, context): self.context = context # by standard, ct directories must be inside IPTS/raw/ct_scans, but older IPTS may not conform # in that case, a general directory selector is used config = context.config if not config.ct_scan_subdirs: return self.createDirSelector() # standard case explanation = ipyw.HTML( "Please choose the sub-directory that contains the image files for your CT scan" ) self.select = ipyw.Select(options=config.ct_scan_subdirs, value=config.ct_scan_subdirs[0], description="CT scans") self.ok = ipyw.Button(description='Select', layout=self.button_layout) self.use_dir_selector = ipyw.Button( description= 'If you cannot find your CT scan above, click me instead', layout=ipyw.Layout(margin="0 0 0 200px", width="350px")) self.widgets = [ explanation, self.select, self.ok, self.use_dir_selector ] self.ok.on_click(self.validate) self.use_dir_selector.on_click(self.switchToDirSelector) self.panel = ipyw.VBox(children=self.widgets, layout=self.layout)
def __init__(self, ml_repo): self._ml_repo = ml_repo self._output = widgets.Output( layout=Layout(width='100%', height='100%')) self._model_selection = widgets.RadioButtons( options=self._ml_repo.get_names(MLObjectType.MODEL), # value='pineapple', description='model:', disabled=False) self._train_model_sel = widgets.RadioButtons( options=['training', 'model'], value='model', description='param type:', disabled=False) self._param_sel = widgets.Select(description='parameter', disabled=False) self._get_parameter() self._train_model_sel.observe(self._get_parameter, 'value') self._data_selection = widgets.SelectMultiple(options=[]) self._get_measures() self._plot_button = widgets.Button(description='plot') self._plot_button.on_click(self.plot) self._widget_main = widgets.VBox(children=[ widgets.HBox(children=[ self._plot_button, self._data_selection, self._model_selection, self._train_model_sel, self._param_sel ]), self._output ])
def _init_field_ctls(self): """Initialize the data field controls.""" fields = {} dl_button = None for field, field_attrs in MORDOR_FIELDS.items(): if field == "file_paths": dl_button = widgets.Button(description="Download") fields[field] = widgets.HBox([ widgets.Select( description=field, layout=self.layouts["layout_norm"], style=self.w_style, ), dl_button, ]) elif field == "simulation": fields[field] = field_attrs["widget"]( description=field, layout=self.layouts["layout_high"], style=self.w_style, ) else: fields[field] = field_attrs["widget"]( description=field, layout=self.layouts["layout_norm"], style=self.w_style, ) self.widgets["fields"] = fields if dl_button is not None: self.widgets["wgt_dl_button"] = dl_button dl_button.on_click(self._download_file)
def show_vibs(calc, amplitude=1): import traitlets import nglview import ipywidgets as widgets from ipywidgets import Layout, HBox, VBox trajs = [] freqs, modes = calc.get_vibrational_modes() freq_list = [ '-%.2f' % (f.real * 1000) if np.iscomplexobj(f) else '%.2f' % (f * 1000) for f in freqs ] for n, mode in enumerate(modes): trajs.append( [a.positions for a in form_traj(calc.atoms, mode, amplitude)]) v = nglview.show_asetraj([calc.atoms]) v.clear_representations() v.add_spacefill(radius_type='vdw', radius_scale=0.5, roughness=1, metalness=0) v._set_size('450px', '300px') v.camera = 'orthographic' v.parameters = dict(clipDist=0, sampleLevel=1) select = widgets.Select(options=freq_list, value=freq_list[-1], layout=Layout(width='100px', height='270px'), disabled=False) play = widgets.Play(value=0, min=-10, max=10, step=1, _repeat=True, description="Press play", disabled=False) slider = widgets.IntSlider( value=0, min=-10, max=10, ) class FnScope: traj = trajs[-1] def handle_slider_change(change): v.set_coordinates({0: FnScope.traj[change.new]}) def handle_select_change(change): FnScope.traj = trajs[change.new] slider.observe(handle_slider_change, names='value') select.observe(handle_select_change, names='index') traitlets.link((play, 'value'), (slider, 'value')) vib_viewer = HBox([VBox([v, HBox([play, slider])]), select]) display(vib_viewer)
def __init__(self): from .config import options if options['backend'] != 'jupyter': raise Exception( 'gui2.PlotShape currently only works with "jupyter" backend') GUIWidget.__init__(self) self._uuid = str(uuid.uuid4()).replace('-', '') self._graph_div = widgets.Output() with self._graph_div: display( HTML( '<div id="%s" style="width:400px; height:400px; border: 1px solid black"></div>' % self._uuid)) self._rangevars_control = widgets.Select(options=['No coloration'], index=0) parent = widgets.HBox([self._graph_div, self._rangevars_control]) display(parent) self._rangevars = [] self._val = [] self._ptrs = [] self._old_selection = None display( HTML('<script>sp%s = new ShapePlot("%s");</script>' % (self._uuid, self._uuid))) _shape_plot_list.append(weakref.ref(self)) self._min = -100 self._max = 100 self._force_redraw = False self._update_colors = 5 self._ready = True
def _init_manager_ui(self): """裁判数据管理界面初始化""" description = widgets.Textarea(value=u'删除选择的裁判本地数据:\n' u'删除所选择的已训练好的本地裁判数据,谨慎操作!\n' u'分享选择的裁判:\n' u'将训练好的裁判数据分享到交易社区,供其他交易者使用\n' u'下载更多的裁判:\n' u'从交易社区,下载更多训练好的裁判数据\n', disabled=False, layout=widgets.Layout(height='150px')) self.manager_umps = widgets.Select(options=[], description=u'本地裁判:', disabled=False, layout=widgets.Layout( width='100%', align_items='stretch')) self.load_train_ump(self.manager_umps) delete_bt = widgets.Button(description=u'删除选择的裁判本地数据', layout=widgets.Layout(width='98%'), button_style='warning') delete_bt.on_click(self._do_delete_ump) share_bt = widgets.Button(description=u'分享选择的裁判', layout=widgets.Layout(width='98%'), button_style='info') share_bt.on_click(permission_denied) down_bt = widgets.Button(description=u'下载更多的裁判', layout=widgets.Layout(width='98%'), button_style='info') down_bt.on_click(permission_denied) return widgets.VBox( [description, self.manager_umps, delete_bt, share_bt, down_bt])
def init_widgets(self): """ Initialize all widgets (layout, options, values). """ self.dropdown_layout = widgets.Layout(width='80%') self.dropdown_style = {'description_width': '0%'} # Proposal directory dropdown self._current_dir = widgets.Text(value=self.parent_dir, layout=widgets.Layout(width='100%')) self._dir = widgets.Select( options=get_dirs(self.parent_dir), value=None, description="Select directory", layout=self.dropdown_layout, style=self.dropdown_style, ) self._open = widgets.Button( description='Open', disabled=False, button_style='', # 'success', 'info', 'warning', 'danger' or '' tooltip='Click to open directory', icon='', ) self._open.on_click(self.handle_button_clicked) self._dir.observe(self.handle_dir_change, names=['value'])
def division_select_widget(): division_list = sorted(list(set(sic_reg['division']))) return widgets.Select(options=division_list, value='Manufacturing', rows=5, description='Division', disabled=False)
def __init__(self, flows, **kwargs): super().__init__(1, 3, grid_gap="10px", **kwargs) self._selector = ipywidgets.Select( layout=ipywidgets.Layout(height="100%", width="initial") ) self._flow_widget = WorkflowWidget(layout=ipywidgets.Layout(flex="1 0 auto")) self._vg_widget = VersionGraftWidget(layout=ipywidgets.Layout(flex="1 0 auto")) self.flows = flows ipywidgets.link((self._selector, "value"), (self, "selected_id")) ipywidgets.link((self._flow_widget, "version"), (self, "selected_version")) traitlets.dlink( (self._selector, "value"), (self._flow_widget, "flow"), transform=lambda flow_id: self._flows_lookup.get(flow_id, None), ) traitlets.dlink((self._flow_widget, "current_vg"), (self._vg_widget, "vg")) self._flow_widget.observe( lambda change: self.set_trait("current_flow", change["new"]), names="flow" ) self._flow_widget.observe( lambda change: self.set_trait("current_vg", change["new"]), names="current_vg", ) self[0, 0] = ipywidgets.VBox( children=[ipywidgets.HTML("<h2>Workflows</h2>"), self._selector], layout=ipywidgets.Layout(flex="1 0 auto"), ) self[0, 1] = self._flow_widget self[0, 2] = self._vg_widget
def __init__(self, dir_name='.', extension=['*']): if dir_name == '.': self.get_directory('.') """elif dir_name == None: fp = open(config_path+'\\path.txt','r') path = fp.read() fp.close() self.get_directory(path) self.dir_name = path """ elif os.path.isdir(dir_name): self.get_directory(dir_name) self.dir_name = dir_name else: self.dir_name = '.' self.get_directory(self.dir_name) self.dir_list == ['.'] self.extensions = extension self.file_name = '' self.select_files = widgets.Select(options=self.dir_list, value=self.dir_list[0], description='Select file:', disabled=False, rows=10, layout=widgets.Layout(width='70%')) display(self.select_files) self.set_options() self.select_files.observe(self.get_file_name, names='value')
def widget(self): # ボタン系 submit_w = widgets.Button(description="登録") submit_w.on_click(self.submit_h) lb0 = widgets.Label(value="cID: %s" % self.data.id) lb1 = widgets.Label(value="タイトル:") title_w = widgets.Text(value="", layout=Layout(width='80%')) title_w.observe(self.submit_h, names='value') # HANDLER lb2 = widgets.Label(value="詳細内容:") self.descriptionTxt = widgets.Textarea(rows=5, layout=Layout(width='90%')) lb3 = widgets.Label(value="サンプル:") config = {"db": self.data.sampleDB, "message": self.sampleList_m} sl = SampleList_w(config) description_w = widgets.Select(options=[], rows=10, disable=True, layout=Layout(width='90%')) del_w = widgets.Button(description="このクラスタを削除") box = widgets.VBox([ lb0, submit_w, lb1, title_w, lb2, descriptionTxt, lb3, description, del_w ]) return box
def plot_one_intervention_horizontal_interactive( plot_one_intervention_horizontal, baseline): folder_path = './model_outcomes/one_intervention/' one_intervention_dict = load_interventions(folder_path) #sort the collection of interventions by their keys one_intervention_dict = { k: v for k, v in sorted(one_intervention_dict.items(), key=lambda item: item[0]) } w = interactive(plot_one_intervention_horizontal, column=widgets.Select(options=[ 'Infected (symptomatic)', 'Hospitalised', 'Critical', 'Deaths' ], value='Infected (symptomatic)', description='Category:'), baseline=fixed(baseline), one_intervention_dict=fixed(one_intervention_dict)) words = widgets.Label( 'Contrast the peak case count between do nothing and a single intervention strategy in place' ) container = widgets.VBox([words, w]) container.layout.width = '100%' container.layout.border = '2px solid grey' container.layout.justify_content = 'space-around' container.layout.align_items = 'center' return container
def _init_train_ui(self): """裁判特征训练面初始化""" description = widgets.Textarea( value=u'裁判特征训练:\n' u'通过在\'裁判特征采集\'选中\'回测过程生成交易特征\'可在回测完成后保存当此回测结果\n' u'所有回测的结果将显示在下面的\'备选回测:\'框中\n' u'通过\'开始训练裁判\'进行指定的回测裁判训练,训练后的裁判在\'裁判预测拦截\'下可进行选择,选中的裁判将在对应的' u'回测中生效,即开始在回测中对交易进行预测拦截等智能交易干涉行为', disabled=False, layout=widgets.Layout(height='150px')) self.abu_result = widgets.Select(options=[], description=u'备选回测:', disabled=False, layout=widgets.Layout( width='100%', align_items='stretch')) self.load_abu_result() train_bt = widgets.Button(description=u'开始训练裁判', layout=widgets.Layout(width='98%'), button_style='info') train_bt.on_click(self._do_train) delete_bt = widgets.Button(description=u'删除选择的备选回测本地数据', layout=widgets.Layout(width='98%'), button_style='warning') delete_bt.on_click(self._do_delete_abu_result) return widgets.VBox( [description, self.abu_result, train_bt, delete_bt])
def country_select_widget(): l = [key for key, v in country_dict.items()] return widgets.Select(options=sorted(l), value='United States of America', row=5, description='Country:', disabled=False)
def __init__(self, errormessages, molin, molout=None): self.molin = molin self.molout = molout self.msg = errormessages self.status = ipy.HTML('<h4>Forcefield assignment: %s</h4>' % ('Success' if molout else 'FAILED')) self.listdesc = ipy.HTML('<b>Errors / warnings:</b>') error_display = collections.OrderedDict((e.short, e) for e in self.msg) if len(error_display) == 0: error_display['No errors or warnings.'] = StructureOk() self.errorlist = ipy.Select(options=error_display) self.errmsg = ipy.HTML('-') self.viewer = self.molin.draw3d() self.viewer.ribbon(opacity=0.7) if self.errorlist.value is not None: self.switch_display({'old': self.errorlist.value, 'new': self.errorlist.value}) self.errorlist.observe(self.switch_display, 'value') children = (self.status, ipy.HBox([self.viewer, ipy.VBox([self.listdesc, self.errorlist])]), self.errmsg) super(ParameterizationDisplay, self).__init__(children=children, layout=ipy.Layout(display='flex', flex_flow='column'))
def __init__(self): self.ch = bioservices.ChEBI() self.kegg = bioservices.KEGG() self.wOntologySelect = w.Dropdown(description='Ontology:', options=['ChEBI', 'KEGG.Reaction']) self.wSearchTerm = w.Text(description='Search Term:', value="glucose") self.wSearchTerm.on_submit(self.search) self.wSearchButton = w.Button(description='Search') self.wSearchButton.on_click(self.search) self.wResultsSelect = w.Select(description='Results:', width='100%') self.wResultsSelect.on_trait_change(self.selectedTerm) self.wResultsURL = w.Textarea(description='URL:', width='100%') self.wResults = w.VBox( children=[self.wResultsSelect, self.wResultsURL], width='100%') for ch in self.wResults.children: ch.font_family = 'monospace' ch.color = '#AAAAAA' ch.background_color = 'black' # <Container> self.wContainer = w.VBox([ self.wOntologySelect, self.wSearchTerm, self.wSearchButton, self.wResults ]) # display the container display(self.wContainer) self.init_display()
def createSelectWidget(self): entries = self.getEntries() entries.sort() self._entries = entries = [ ' .', ' ..', ] + entries if self.multiple: value = [] self.select = ipyw.SelectMultiple( value=value, options=entries, description="Select", layout=self.select_multiple_layout) else: value = entries[0] self.select = ipyw.Select(value=value, options=entries, description="Select", layout=self.select_layout) """When ipywidgets 7.0 is released, the old way that the select or select multiple widget was set up (see below) should work so long as self.select_layout is changed to include the display="flex" and flex_flow="column" statements. In ipywidgets 6.0, this doesn't work because the styles of the select and select multiple widgets are not the same. self.select = widget( value=value, options=entries, description="Select", layout=self.select_layout) """ return self.select
def create_widgets(self, file_list): control_label = ipywidgets.Label( value= 'Select file and add the result data shown on the right to the plot.' ) def sortfun(x): splitted = x.rsplit('_', maxsplit=2) return splitted[0], splitted[1], splitted[2][:-4] self.results_select = ipywidgets.Select(options=sorted(file_list, key=sortfun), rows=20) self.data_select = ipywidgets.Select( placeholder='Select file.', rows=20, layout=ipywidgets.Layout(width='30%')) self.results_show = ipywidgets.Textarea( layout=ipywidgets.Layout(width='auto', height='100%')) self.add_to_plot_btn = ipywidgets.Button( description='Add to plot', layout=ipywidgets.Layout(width='auto')) self.clear_btn = ipywidgets.Button( description='Clear', layout=ipywidgets.Layout(width='auto')) self.save_btn = ipywidgets.Button( description='Save', layout=ipywidgets.Layout(width='auto')) self.verbose_plot_checkbox = ipywidgets.Checkbox( value=True, description='Verbose plot.', disabled=False, layout=ipywidgets.Layout(width='auto')) select_box = ipywidgets.HBox([self.results_select, self.data_select]) control_box = ipywidgets.VBox([ control_label, select_box, self.add_to_plot_btn, self.clear_btn, self.save_btn, self.verbose_plot_checkbox ]) show_box = ipywidgets.VBox([self.results_show], layout=ipywidgets.Layout( align_items='stretch', flex='1 1 auto')) self.main_widget = ipywidgets.HBox( [control_box, show_box], layout=ipywidgets.Layout(border='solid'))
def state_select_widget(countryba): if countryba == 'US': with open('us_state_list.pickle', 'rb') as f: us_state_list = pickle.load(f) return widgets.Select(options=list(us_state_list), value='VA', row=5, description='US State:', disabled=False) if countryba == 'CA': with open('canada_state_list.pickle', 'rb') as f: canada_state_list = pickle.load(f) return widgets.Select(options=list(canada_state_list), value='ON', row=5, description='Canada State:', disabled=False)
def display(self): options = [] output = self._sf_output for i in range(len(output['runs'])): run = output['runs'][i] options.append(run['dataset']['id'] + ' ::: ' + run['alg']['name']) self._W = widgets.Select(options=options) display(self._W)
def industry_select_widget(div): industry_list = sorted( list(set(sic_reg[sic_reg['division'] == div]['industry']))) return widgets.Select(options=industry_list, value=industry_list[0], rows=5, description='Industry', disabled=False)
def publication_year_widget(df): """ Create a widget with a list of available years """ start_year = vpd.start_year(df) end_year = vpd.end_year(df) year_range = np.arange(start_year, end_year + 1) return widgets.Select(options=year_range, description="Choose", disabled=False)
def get_neighborhood_options(self, options: dict, phase: Option): available = widgets.Dropdown(options=[m[0] for m in options[phase]], description=phase.value) size = widgets.IntText(value=1, description='k: ', layout=widgets.Layout(width='150px')) add = widgets.Button(description='', icon='chevron-right', layout=widgets.Layout(width='60px'), tooltip='add ' + phase.name) remove = widgets.Button(description='', icon='chevron-left', layout=widgets.Layout(width='60px'), tooltip='remove ' + phase.name) up = widgets.Button(description='', icon='chevron-up', layout=widgets.Layout(width='30px'), tooltip='up ' + phase.name) down = widgets.Button(description='', icon='chevron-down', layout=widgets.Layout(width='30px'), tooltip='down ' + phase.name) def on_change_available(event): opt = handler.get_options(Problem(self.problemWidget.value), Algorithm(self.algoWidget.value)) opt = [o for o in opt.get(phase) if o[0] == available.value][0] size.value = 1 if opt[1] == None or type( opt[1]) == type else opt[1] size.disabled = type(opt[1]) != type or opt[1] == None on_change_available(None) def on_change_size(change): if change.new < 1: change.owner.value = 1 size.observe(on_change_size, names='value') available.observe(on_change_available, names='value') selected = widgets.Select(options=[], description='Selected') self.optionsHandles[phase] = selected add.on_click(self.on_add_neighborhood) remove.on_click(self.on_remove_neighborhood) up.on_click(self.on_up_neighborhood) down.on_click(self.on_down_neighborhood) middle = widgets.Box([size, add, remove], layout=widgets.Layout(display='flex', flex_flow='column', align_items='flex-end')) sort = widgets.VBox([up, down]) return widgets.HBox([available, middle, selected, sort])
def __init__( self, df, group_keys=None, filter_key=None, filter_values=None, method='max', plot_type='bar', output_file=None, transpose=True, ): self.df = df self.filtered_df = df index_names = sorted(df.index.names) self.w_parameters = widgets.SelectMultiple( options=index_names, value=group_keys if group_keys is not None else [index_names[0]], description='Group By', ) valid_methods = ['min', 'max', 'mean', 'box'] self.w_method = widgets.RadioButtons( options=valid_methods, value=method if method in valid_methods else 'max') self.w_method.observe(self.update_available_plot_types) valid_plot_types = ['line', 'bar'] self.w_plot_type = widgets.RadioButtons( options=valid_plot_types, value=plot_type if plot_type in valid_plot_types else 'bar', ) self.w_transpose = widgets.Checkbox(description='transpose', value=transpose) self.w_filter_key = widgets.Select( options=[''] + index_names[:], description='Filter field', value=filter_key if filter_key is not None else '', ) self.w_filter_value = widgets.SelectMultiple( options=[], description='Filter value') self.update_possible_filter_values(None) if filter_values is not None: self.w_filter_value.value = filter_values self.w_file_name = widgets.Text( value=output_file if output_file is not None else '', description='output CSV Path', ) self.w_overwrite = widgets.Checkbox( description='allows overwriting output files') self.w_output_button = widgets.Button(description='Generate CSV') self.w_export_output = widgets.Output() self.w_filter_key.observe(self.update_possible_filter_values) self.w_output_button.on_click(self.csv_callback) self.display()