How to use the ipywidgets.Dropdown function in ipywidgets

To help you get started, we’ve selected a few ipywidgets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hachmannlab / chemml / cheml / notebooks / main.py View on Github external
m = p[1].strip().split('      >>>      ')
                edge = (int(p[0]), m[0].strip(), int(m[1]), p[2].strip())
                if edge in self.comp_graph:
                    self.comp_graph.remove(edge)
            refresh_tasks()
            display_graph()


        self.pages[self.current_bid].IO_refresher = refresh_tasks

        ## Sender
        output_tokens = [token for token in self.pages[self.current_bid].block_params['outputs']]
        headerS = widgets.HTML(value='<b> Send &gt;&gt;&gt; </b>', layout=widgets.Layout(width='50%',margin='10px 0px 0px 10px'))
        # listS = widgets.HTML(value='output tokens: %s'%', '.join(sorted(output_tokens)), \
        #                      layout=widgets.Layout(margin='3px 0px 0px 20px'))
        sender = widgets.Dropdown(
            options=sorted(output_tokens),
            # value=output_tokens[0],
            description='output token:')
        hbox1S = widgets.HBox([sender],layout=widgets.Layout(height='40px', border='dotted black 1px',
                                                               align_items='center',  # justify_content = 'center',
                                                               margin='0px 0px 0px 10px'))
        toS = widgets.HTML(value='<b> &gt;&gt;&gt; </b>')
        bidS_options = [i for i in self.pages if i not in [0, 1]]
        rm_n_2S = remove_nodes_toSEND(self.current_bid,set())
        for n in rm_n_2S:
            bidS_options.remove(n)
        bidS = widgets.Dropdown(
            options=sorted(bidS_options),
            description='block#:',
            layout=widgets.Layout(width='140px'))
        bidS.observe(bidS_value_change,names='value')
github microsoft / ELL / interfaces / python / package / ell / util / gallery.py View on Github external
def choose_model(self):
        from ipywidgets import interact
        import ipywidgets as widgets
        from .pretrained_model import PretrainedModel

        'Provide an interactive way to choose between models and call a callback when a choice is made'
        keys = list(self.grouped.keys())
        size_dropdown = widgets.Dropdown(options=keys, description='Size')
        arch_dropdown = widgets.Dropdown(
            options=[d['layers'] for d in self.grouped[keys[0]]],
            description='Layers')

        def update_arch(*args):
            'update the architecture choices for the latest size choice'
            idx = size_dropdown.options.index(size_dropdown.value)
            arch_dropdown.options = [
                d['layers'] for d in self.grouped[keys[idx]]
            ]

        size_dropdown.observe(update_arch, 'value')

        def choose(size, layers):
            'call the callback when the user makes interactive choices'
            try:
github ideonate / jupyter-innotater / jupyter-innotater / jupyter_innotater / data.py View on Github external
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)
github cosmo-epfl / librascal / examples / utilities / vectors_utils.py View on Github external
description=hyper_vals[val]['name'],
                                         )
                        for val in hyper_vals if 'fixed' not in hyper_vals[val]}

        # Which elements to center smooth gaussians on. Defaults to all elements
        # present except for hydrogen.
        constituents = list(set([s for k in self.symbols for s in self.symbols[k]]))
        self.sliders['center_select']=widgets.SelectMultiple(
                                    options=constituents,
                                    value=[s for s in constituents if s != "H"],
                                    description="Where to Place SOAP Centers",
                                    style=style)

        # Whether to compute the global kernel (average of the environments) or
        # atomic kernel.
        self.sliders['average'] = widgets.Dropdown(
            options=["Environment-Centered", "Average"],
            value="Environment-Centered",
            description="Type of SOAP Vectors",
            style=style)

        # Show and enable the widgets if interactive==True
        if(interactive):
            self.preset_button = _button_template_(list(hyper_dict.keys()),
                                                   "SOAP Presets: ",
                                                   self.preset_func)
            if(isinstance(hyperparameters, str)):
                self.preset_button.value = hyperparameters

            slider_order = ['center_select',
                            'average',
                            *list(hyper_vals.keys())]
github pailabteam / pailab / pailab / analysis / tools_jupyter.py View on Github external
def _get_recommendation_widget(self):
        self._update_recommendation = widgets.Button(description='update')
        self._max_num_recommendations = widgets.IntText(value=20,
                                                        description='maximum number of recommendations')
        self._cache_in_repo = widgets.Checkbox(
            value=True, description='cache MMD in repo')
        self._scale = widgets.Checkbox(
            value=True, description='scale x-values to zero mean and unit variance')
        self._update_recommendation.on_click(self._recommend)
        self._kernel_selection = widgets.Dropdown(options=[
            'rbf', 'linear', 'polynomial', 'sigmoid', 'laplacian', 'chi2'
        ],
            value='rbf',
            description='kernel')
        self._gamma = widgets.FloatText(value=1.0, description='gamma')
        self._gamma_for_kernel = [
            'rbf', 'polynomial', 'sigmoid', 'laplacian', 'chi2']
        self._kernel_selection.observe(self._on_kernel_change, names='value')
        self._recommendation_selection = widgets.IntText(
            description='recommendation id')
        self._recomendation_selection_apply = widgets.Button(
            description='apply recommendation')
        self._recomendation_selection_apply.on_click(self._apply_recommend)
        return widgets.VBox(children=[
            self._max_num_recommendations,
            self._cache_in_repo,
github twosigma / beakerx / beakerx / beakerx / beakerx_widgets.py View on Github external
super(BeakerxButton, self).__init__(**kwargs)

    _view_module = Unicode('@jupyter-widgets/controls').tag(sync=True)
    _model_module = Unicode('@jupyter-widgets/controls').tag(sync=True)
    _model_module_version = Unicode('*').tag(sync=True)
    _view_module_version = Unicode('*').tag(sync=True)
    align_self = Unicode('*').tag(sync=True)

    layout = InstanceDict(BeakerxLayout).tag(sync=True, **widget_serialization)
    style = None

    def actionPerformed(self, *args, **kwargs):
        pass


class BeakerxComboBox(Dropdown, EasyFormComponent):
    def __init__(self, **kwargs):
        super(BeakerxComboBox, self).__init__(**kwargs)

    _view_name = Unicode('ComboBoxView').tag(sync=True)
    _model_name = Unicode('ComboBoxModel').tag(sync=True)
    _view_module = Unicode('beakerx').tag(sync=True)
    _model_module = Unicode('beakerx').tag(sync=True)
    _model_module_version = Unicode('*').tag(sync=True)
    _view_module_version = Unicode('*').tag(sync=True)
    editable = Bool(default_value=False).tag(sync=True)
    original_options = Union([List(), Dict()])
    style = None

    def _handle_msg(self, msg):
        if 'value' in msg['content']['data']['state']:
            value = msg['content']['data']['state']['value']
github abinit / abipy / abipy / display / utils.py View on Github external
def colors_dropdow(default="None"):
    return ipw.Dropdown(
        options=_mpl_colors,
        value=default,
        description='color',
    )
github kboone / avocado / code / plasticc_gp_bak.py View on Github external
def plot_gp_interactive(self):
        """Make an interactive plot of the GP output.

        This requires the ipywidgets package to be set up, and has only been
        tested in jupyter-lab.
        """
        from ipywidgets import interact, IntSlider, Dropdown, fixed

        targets = np.unique(self.meta_data['target'])

        idx_widget = IntSlider(min=0, max=1)
        target_widget = Dropdown(options=targets, index=0)

        def update_idx_range(*args):
            idx_widget.max = np.sum(self.meta_data['target'] ==
                                    target_widget.value) - 1
            target_widget.observe(update_idx_range, 'value')
        update_idx_range()

        interact(self.plot_gp, idx=idx_widget, target=target_widget,
                 object_meta=fixed(None), object_data=fixed(None))
github gee-community / gee_tools / geetools / ui / ipymap.py View on Github external
if len(visMax) == 1:
                        vismaxR = vismaxG = vismaxB = visMax[0]
                    else:
                        vismaxR = visMax[0]
                        vismaxG = visMax[1]
                        vismaxB = visMax[2]

                    if len(visBands) == 1:
                        visbandR = visbandG = visbandB = visBands[0]
                    else:
                        visbandR = visBands[0]
                        visbandG = visBands[1]
                        visbandB = visBands[2]

                    drop = Dropdown(description='red', options=imbands, value=visbandR)
                    drop2 = Dropdown(description='green', options=imbands, value=visbandG)
                    drop3 = Dropdown(description='blue', options=imbands, value=visbandB)
                    slider = FloatRangeSlider(min=min_dict[drop.value],
                                              max=max_dict[drop.value],
                                              value=[visminR, vismaxR],
                                              step=0.01)
                    slider2 = FloatRangeSlider(min=min_dict[drop2.value],
                                               max=max_dict[drop2.value],
                                               value=[visminG, vismaxG],
                                               step=0.01)
                    slider3 = FloatRangeSlider(min=min_dict[drop3.value],
                                               max=max_dict[drop3.value],
                                               value=[visminB, vismaxB],
                                               step=0.01)
                    # set handlers
                    drop.observe(handle_dropdown(slider), names=['value'])
github exa-analytics / exatomic / exatomic / widgets / widget.py View on Github external
"""Folder that houses field GUI controls."""
        folder = super(DemoUniverse, self)._field_folder(**kwargs)
        uni_field_lists = _ListDict([
            ('Hydrogenic', ['1s',   '2s',   '2px', '2py', '2pz',
                            '3s',   '3px',  '3py', '3pz',
                            '3d-2', '3d-1', '3d0', '3d+1', '3d+2']),
            ('Gaussian', ['s', 'px', 'py', 'pz', 'd200', 'd110',
                          'd101', 'd020', 'd011', 'd002', 'f300',
                          'f210', 'f201', 'f120', 'f111', 'f102',
                          'f030', 'f021', 'f012', 'f003']),
            ('SolidHarmonic', [str(i) for i in range(8)])])
        kind_widgets = _ListDict([
            (key, Dropdown(options=vals))
            for key, vals in uni_field_lists.items()])
        ml_widgets = _ListDict([
            (str(l), Dropdown(options=[str(i) for i in range(-l, l+1)]))
            for l in range(8)])
        fopts = list(uni_field_lists.keys())
        folder.update(kind_widgets, relayout=True)
        folder.update(ml_widgets, relayout=True)

        def _field(c):
            fk = uni_field_lists[c.new][0]
            for scn in self.active():
                scn.field = c.new
                scn.field_kind = fk
            folder.deactivate(c.old)
            folder[c.new].value = fk
            folder.activate(c.new, enable=True)
            if c.new == 'SolidHarmonic':
                folder.activate(fk, enable=True)
            else: