Python ipywidgets.Select() Examples
The following are 14
code examples of ipywidgets.Select().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ipywidgets
, or try the search function
.
Example #1
Source File: data.py From jupyter-innotater with MIT License | 5 votes |
def _create_widget(self): if self.dropdown: return Dropdown(options=self.classes, layout=self.layout, disabled=self.disabled) return Select(options=self.classes, layout=self.layout, disabled=self.disabled)
Example #2
Source File: nbwidgets.py From msticpy with MIT License | 5 votes |
def _select_alert(self, selection=None): """Select action triggered by picking item from list.""" if ( selection is None or "new" not in selection or not isinstance(selection["new"], str) ): self.selected_alert = None else: self.alert_id = selection["new"] self.selected_alert = self._get_alert(self.alert_id) if self.alert_action is not None: self._run_action()
Example #3
Source File: nbwidgets.py From msticpy with MIT License | 5 votes |
def _select_top_alert(self): """Select the first alert by default.""" top_alert = self.alerts.iloc[0] if not top_alert.empty: self.alert_id = top_alert.SystemAlertId self.selected_alert = self._get_alert(self.alert_id) if self.alert_action is not None: self._run_action()
Example #4
Source File: gui.py From pyiron with BSD 3-Clause "New" or "Revised" License | 5 votes |
def create_widgets(self): """ Returns: """ select = widgets.Select # Multiple self.w_group = select(description="Groups:") self.w_node = select(description="Nodes:") self.w_file = select(description="Files:") self.w_text = widgets.HTML() # self.w_text = widgets.Textarea() self.w_text.layout.height = "330px" self.w_text.layout.width = "580px" self.w_text.disabled = True # self.w_plot = self.fig w_list = widgets.VBox([self.w_group, self.w_node, self.w_file]) self.w_tab = widgets.HBox([w_list, self.w_text]) # tab = widgets.Tab(children=[self.w_group, self.w_node, self.w_file, self.w_text]) # [tab.set_title(num, name) for num, name in enumerate(['groups', 'nodes', 'files', 'text'])] # self.w_tab = tab self.w_path = widgets.Text(name="Path: ") self.w_path.layout.width = "680px" self.w_type = widgets.Text(name="Type: ") self.refresh_view()
Example #5
Source File: test_widget_selection.py From pySINDy with MIT License | 5 votes |
def test_construction(self): select = Select(options=['a', 'b', 'c'])
Example #6
Source File: test_widget_selection.py From pySINDy with MIT License | 5 votes |
def test_index_trigger(self): select = Select(options=[1, 2, 3]) observations = [] def f(change): observations.append(change.new) select.observe(f, 'index') assert select.index == 0 select.options = [4, 5, 6] assert select.index == 0 assert select.value == 4 assert select.label == '4' assert observations == [0]
Example #7
Source File: ontologysearch.py From tellurium with Apache License 2.0 | 5 votes |
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()
Example #8
Source File: parameterization.py From notebook-molecular-visualization with Apache License 2.0 | 5 votes |
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, HBox([self.viewer, VBox([self.listdesc, self.errorlist])]), self.errmsg) super().__init__(children=children, layout=ipy.Layout(display='flex', flex_flow='column'))
Example #9
Source File: ABuWGUmp.py From abu with GNU General Public License v3.0 | 5 votes |
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])
Example #10
Source File: ABuWGUmp.py From abu with GNU General Public License v3.0 | 5 votes |
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])
Example #11
Source File: nbwidgets.py From msticpy with MIT License | 4 votes |
def __init__( self, default: int = 4, label: str = "Select time ({units}) to look back", origin_time: datetime = None, min_value: int = 1, max_value: int = 240, units: str = "hour", auto_display: bool = False, ): """ Create an instance of the lookback slider widget. Parameters ---------- default : int, optional The default 'lookback' time (the default is 4) label : str, optional The description to display (the default is 'Select time ({units}) to look back') origin_time : datetime, optional The origin time (the default is `datetime.utcnow()`) min_value : int, optional Minimum value (the default is 1) max_value : int, optional Maximum value (the default is 240) units : str, optional Time unit (the default is 'hour') Permissable values are 'day', 'hour', 'minute', 'second' These can all be abbreviated down to initial characters ('d', 'm', etc.) auto_display : bool, optional Whether to display on instantiation (the default is False) """ # default to now self.origin_time = datetime.utcnow() if origin_time is None else origin_time self._time_unit = _parse_time_unit(units) if "{units}" in label: label = label.format(units=self._time_unit.name) self._lookback_wgt = widgets.IntSlider( value=default, min=min_value, max=max_value, step=1, description=label, layout=Layout(width="60%", height="50px"), style={"description_width": "initial"}, ) self.end = self.origin_time self._time_unit = _parse_time_unit(units) self.start = self.end - timedelta( seconds=(self._time_unit.value * self._lookback_wgt.value) ) self._lookback_wgt.observe(self._time_range_change, names="value") if auto_display: self.display()
Example #12
Source File: nbwidgets.py From msticpy with MIT License | 4 votes |
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%", display_filter: bool = True, ): """ 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%') display_filter : bool, optional Whether to display item filter (the default is True) """ self._w_output = widgets.Output(layout={"border": "1px solid black"}) super().__init__( description=description, item_list=item_list, item_dict=item_dict, action=action, auto_display=auto_display, height=height, width=width, display_filter=display_filter, )
Example #13
Source File: speciessearch.py From tellurium with Apache License 2.0 | 4 votes |
def __init__(self, debug=False): """ Creates and displays the search form. """ self.debug = debug self.s = bioservices.BioModels() self.ch = bioservices.ChEBI() # Define widgets # <Search> self.wSearchTerm = w.Text(description='Search biomodels by species:', value="CHEBI:17925") self.wSearchTerm.on_submit(self.searchChebi) self.wSearchButton = w.Button(description='Search') self.wSearchButton.on_click(self.searchChebi) self.wSearchChebi = w.HBox(children=[ self.wSearchTerm, self.wSearchButton ]) self.wSelectChebis = w.Select(description='Matching ChEBI:', width='600px', height='250px') # FIXME: update the deprecated functions self.wSelectChebis.on_trait_change(self.selectChebi) self.wSelectModels = w.Select(description='Matching BioModels:', width='200px') self.wSelectModels.on_trait_change(self.selectedModel) # <Model> self.wModelId = w.Text(description='Model ID:', value="No model selected") self.wModelCode = w.Text(description='Install Code:') self.wModelImport = w.Text(description='Import module code:') self.wModelSbml = w.Textarea(description='Model SBML:', width='800px', height='300px') # <Container> self.wModel = w.VBox([ self.wModelId, self.wModelCode, self.wSelectModels, self.wModelImport, self.wModelSbml ]) for ch in self.wModel.children: ch.font_family = 'monospace' ch.color = '#AAAAAA' ch.background_color = 'black' self.wContainer = w.VBox([ self.wSearchChebi, self.wSelectChebis, self.wModel ]) # display the widgets display(self.wContainer)
Example #14
Source File: symmetry.py From notebook-molecular-visualization with Apache License 2.0 | 4 votes |
def __init__(self, mol): self._current_shapes = [] self.mol = mol self.tolerance = 0.3 * u.angstrom self.original_coords = mol.positions.copy() self.showing = ipy.HTML() self.viewer = mol.draw3d(width='650px') """:type viewer: moldesign.viewer.GeometryViewer""" self.description = ipy.HTML() self.symm_selector = ipy.Select() self.symm_selector.observe(self.show_symmetry, names='value') self.apply_button = ipy.Button(description='Symmetrize') self.apply_button.on_click(self.apply_selected_symmetry) self.reset_button = ipy.Button(description='Reset') self.reset_button.on_click(self.reset_coords) self.apply_all_button = ipy.Button(description='Apply all', layout=ipy.Layout(padding='10px')) self.apply_all_button.on_click(self.set_highest_symmetry) self.tolerance_descrip = ipy.HTML(u'<small>tolerance/\u212B</small>',) self.tolerance_chooser = ipy.BoundedFloatText(value=self.tolerance.value_in(u.angstrom), min=0.0) self.recalculate_button = ipy.Button(description='Recalculate') self.recalculate_button.on_click(self.coords_changed) self.symm_pane = VBox([self.description, self.symm_selector, HBox([self.apply_button, self.reset_button]), self.apply_all_button, HBox([self.tolerance_chooser, self.recalculate_button]), self.tolerance_descrip], layout=ipy.Layout(width='325px')) self.symmetry = None self.coords_changed() self.hbox = HBox([VBox([self.viewer, self.showing]), self.symm_pane]) super().__init__([self.hbox])