當前位置: 首頁>>代碼示例>>Python>>正文


Python ipywidgets.Dropdown方法代碼示例

本文整理匯總了Python中ipywidgets.Dropdown方法的典型用法代碼示例。如果您正苦於以下問題:Python ipywidgets.Dropdown方法的具體用法?Python ipywidgets.Dropdown怎麽用?Python ipywidgets.Dropdown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ipywidgets的用法示例。


在下文中一共展示了ipywidgets.Dropdown方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_dict

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Dropdown [as 別名]
def test_dict():
    for d in [
        dict(a=5),
        dict(a=5, b='b', c=dict),
    ]:
        c = interactive(f, d=d)
        w = c.children[0]
        check = dict(
            cls=widgets.Dropdown,
            description='d',
            value=next(iter(d.values())),
            options=d,
            _options_labels=tuple(d.keys()),
            _options_values=tuple(d.values()),
        )
        check_widget(w, **check) 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:18,代碼來源:test_interaction.py

示例2: test_default_out_of_bounds

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Dropdown [as 別名]
def test_default_out_of_bounds():
    @annotate(f=(0, 10.), h={'a': 1}, j=['hi', 'there'])
    def f(f='hi', h=5, j='other'):
        pass

    c = interactive(f)
    check_widgets(c,
        f=dict(
            cls=widgets.FloatSlider,
            value=5.,
        ),
        h=dict(
            cls=widgets.Dropdown,
            options={'a': 1},
            value=1,
        ),
        j=dict(
            cls=widgets.Dropdown,
            options=('hi', 'there'),
            value='hi',
        ),
    ) 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:24,代碼來源:test_interaction.py

示例3: metal_distance_widget

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Dropdown [as 別名]
def metal_distance_widget(df_concat):
    '''Plot an violinplot of metal-element distances with ipywidgets

    Parameters
    ----------
    df_concat : Dataframe
       dataframe of metal-elements distances

    '''
    metals = df_concat['Metal'].unique().tolist()
    m_widget = Dropdown(options = metals, description = "Metals")

    def metal_distance_violinplot(metal):
        df_metal = df_concat[df_concat["Metal"] == metal].copy()
        df_metal['Element'] = df_metal['Element'].apply(lambda x: metal+"-"+x)

        # Set fonts
        fig, ax = plt.subplots()
        fig.set_size_inches(15,6)
        subplot = sns.violinplot(x="Element", y="Distance", palette="muted", data=df_metal, ax=ax)
        subplot.set(xlabel="Metal Interactions", ylabel="Distance", title=f"{metal} to Elements Distances Violin Plot")

    return interact(metal_distance_violinplot, metal=m_widget); 
開發者ID:sbl-sdsc,項目名稱:mmtf-pyspark,代碼行數:25,代碼來源:structureViewer.py

示例4: add_text

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Dropdown [as 別名]
def add_text(self, text, shading={}):
        self.update_shading(shading)
        tt = p3s.TextTexture(string=text, color=self.s["text_color"])
        sm = p3s.SpriteMaterial(map=tt)
        self.text = p3s.Sprite(material=sm, scaleToTexture=True)
        self.scene.add(self.text)

    #def add_widget(self, widget, callback):
    #    self.widgets.append(widget)
    #    widget.observe(callback, names='value')

#    def add_dropdown(self, options, default, desc, cb):
#        widget = widgets.Dropdown(options=options, value=default, description=desc)
#        self.__widgets.append(widget)
#        widget.observe(cb, names="value")
#        display(widget)

#    def add_button(self, text, cb):
#        button = widgets.Button(description=text)
#        self.__widgets.append(button)
#        button.on_click(cb)
#        display(button) 
開發者ID:skoch9,項目名稱:meshplot,代碼行數:24,代碼來源:Viewer.py

示例5: __init__

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Dropdown [as 別名]
def __init__(self, mol):
        super().__init__(mol)

        self.selection_type = ipy.Dropdown(description='Clicks select:',
                                           value=self.viewer.selection_type,
                                           options=('Atom', 'Residue', 'Chain'))

        traitlets.link((self.selection_type, 'value'), (self.viewer, 'selection_type'))

        self.residue_listname = ipy.Label('Selected residues:', layout=ipy.Layout(width='100%'))
        self.residue_list = ipy.SelectMultiple(options=list(), height='150px')
        self.viewer.observe(self._update_reslist, 'selected_atom_indices')

        self.residue_list.observe(self.remove_atomlist_highlight, 'value')
        self.atom_list.observe(self.remove_reslist_highlight, 'value')

        self.subtools.children = [self.representation_buttons]
        self.subtools.layout.flex_flow = 'column'
        self.toolpane.children = [self.selection_type,
                                  HBox([self.select_all_atoms_button, self.select_none]),
                                  self.atom_listname,
                                  self.atom_list,
                                  self.residue_listname,
                                  self.residue_list] 
開發者ID:Autodesk,項目名稱:notebook-molecular-visualization,代碼行數:26,代碼來源:selection.py

示例6: _init_feature_ui

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Dropdown [as 別名]
def _init_feature_ui(self):
        """裁判特征采集界麵初始化"""
        ml_feature_description = widgets.Textarea(
            value=u'裁判特征采集\n'
                  u'裁判是建立在機器學習技術基礎上的,所以必然會涉及到特征,abu量化係統支持在回測過程中生成特征數據,切分訓練測試集,'
                  u'甚至成交買單快照圖片,通過打開下麵的開關即可在生成最終的輸出結果數據訂單信息上加上買入時刻的很多信息,'
                  u'比如價格位置、趨勢走向、波動情況等等特征, 注意需要生成特征後回測速度效率會降低\n'
                  u'如在下拉選擇中選中\'回測過程生成交易特征\'在回測完成後將保存回測結果,通過在\'裁判特征訓練\'可進行查看並進行'
                  u'裁判訓練',
            disabled=False,
            layout=widgets.Layout(height='150px')
        )

        self.enable_ml_feature = widgets.Dropdown(
            options={u'回測過程不生成交易特征': 0,
                     u'回測過程生成交易特征': 1},
            value=0,
            description=u'特征生成:',
        )
        return widgets.VBox([ml_feature_description, self.enable_ml_feature]) 
開發者ID:bbfamily,項目名稱:abu,代碼行數:22,代碼來源:ABuWGUmp.py

示例7: _init_widget

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Dropdown [as 別名]
def _init_widget(self):
        """構建AbuWeekMonthBuy策略參數界麵"""

        self.description = widgets.Textarea(
            value=u'固定周期買入策略:\n'
                  u'根據參數每周買入一次或者每一個月買入一次\n'
                  u'需要與特定\'選股策略\'和\'賣出策略\'形成配合\n,'
                  u'單獨使用固定周期買入策略意義不大',
            description=u'定期買入',
            disabled=False,
            layout=self.description_layout
        )

        is_buy_month_label = widgets.Label(u'可更改買入定期,默認定期一個月', layout=self.label_layout)
        self.is_buy_month = widgets.Dropdown(
            options={u'定期一個月': True, u'定期一個周': False},
            value=True,
            description=u'定期時長:',
        )
        is_buy_month_box = widgets.VBox([is_buy_month_label, self.is_buy_month])

        self.widget = widgets.VBox([self.description, is_buy_month_box, self.add],  # border='solid 1px',
                                   layout=self.widget_layout) 
開發者ID:bbfamily,項目名稱:abu,代碼行數:25,代碼來源:ABuWGBuyFactor.py

示例8: _create_widget

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Dropdown [as 別名]
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) 
開發者ID:ideonate,項目名稱:jupyter-innotater,代碼行數:6,代碼來源:data.py

示例9: __init__

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Dropdown [as 別名]
def __init__(self, case, *args, **kwargs):

        self.case = case

        super(CaseView, self).__init__(**kwargs)

        self.generator_names = ipyw.Dropdown(
            options=list(self.case.gen.index)
        )

        children = [
            self.generator_names,
        ]

        self.children = children 
開發者ID:power-system-simulation-toolbox,項目名稱:psst,代碼行數:17,代碼來源:case.py

示例10: plot_interactive

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Dropdown [as 別名]
def plot_interactive(self):
        """Make an interactive plot of the light curves in the dataset.

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

        object_classes = {"": None}
        for object_class in np.unique(self.metadata["class"]):
            object_classes[object_class] = object_class

        idx_widget = IntSlider(min=0, max=1)
        class_widget = Dropdown(options=object_classes, index=0)

        def update_idx_range(*args):
            if class_widget.value is None:
                idx_widget.max = len(self.metadata) - 1
            else:
                idx_widget.max = (
                    np.sum(self.metadata["class"] == class_widget.value) - 1
                )

        class_widget.observe(update_idx_range, "value")

        update_idx_range()

        interact(
            self.plot_light_curve,
            index=idx_widget,
            object_class=class_widget,
            show_gp=True,
            uncertainties=True,
            verbose=False,
            subtract_background=True,
        ) 
開發者ID:kboone,項目名稱:avocado,代碼行數:38,代碼來源:dataset.py

示例11: interact

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Dropdown [as 別名]
def interact(self):
        """Drives the interactive display of the plot explorer panels"""
        param_min = self.param_vals[0]
        param_max = self.param_vals[-1]
        param_step = self.param_vals[1] - self.param_vals[0]

        qbt_indices = [index for (index, subsystem) in self.sweep.qbt_subsys_list]
        osc_indices = [index for (index, subsystem) in self.sweep.osc_subsys_list]

        param_slider = ipywidgets.FloatSlider(min=param_min, max=param_max, step=param_step,
                                              description=self.param_name, continuous_update=False)
        photon_slider = ipywidgets.IntSlider(value=1, min=1, max=4, description='photon number')
        initial_slider = ipywidgets.IntSlider(value=0, min=0, max=self.evals_count, description='initial state index')
        final_slider = ipywidgets.IntSlider(value=1, min=1, max=self.evals_count, description='final state index')

        qbt_dropdown = ipywidgets.Dropdown(options=qbt_indices, description='qubit subsys')
        osc_dropdown = ipywidgets.Dropdown(options=osc_indices, description='oscillator subsys')

        def update_min_final_index(*args):
            final_slider.min = initial_slider.value + 1

        initial_slider.observe(update_min_final_index, 'value')

        out = ipywidgets.interactive_output(self.plot_explorer_panels,
                                            {'param_val': param_slider,
                                             'photonnumber': photon_slider,
                                             'initial_index': initial_slider,
                                             'final_index': final_slider,
                                             'qbt_index': qbt_dropdown,
                                             'osc_index': osc_dropdown
                                             })

        left_box = ipywidgets.VBox([param_slider])
        mid_box = ipywidgets.VBox([initial_slider, final_slider, photon_slider])
        right_box = ipywidgets.VBox([qbt_dropdown, osc_dropdown])

        user_interface = ipywidgets.HBox([left_box, mid_box, right_box])
        display(user_interface, out) 
開發者ID:scqubits,項目名稱:scqubits,代碼行數:40,代碼來源:explorer.py

示例12: test_list_str

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Dropdown [as 別名]
def test_list_str():
    values = ['hello', 'there', 'guy']
    first = values[0]
    c = interactive(f, lis=values)
    nt.assert_equal(len(c.children), 2)
    d = dict(
        cls=widgets.Dropdown,
        value=first,
        options=tuple(values),
        _options_labels=tuple(values),
        _options_values=tuple(values),
    )
    check_widgets(c, lis=d) 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:15,代碼來源:test_interaction.py

示例13: test_list_int

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Dropdown [as 別名]
def test_list_int():
    values = [3, 1, 2]
    first = values[0]
    c = interactive(f, lis=values)
    nt.assert_equal(len(c.children), 2)
    d = dict(
        cls=widgets.Dropdown,
        value=first,
        options=tuple(values),
        _options_labels=tuple(str(v) for v in values),
        _options_values=tuple(values),
    )
    check_widgets(c, lis=d) 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:15,代碼來源:test_interaction.py

示例14: test_list_tuple

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Dropdown [as 別名]
def test_list_tuple():
    values = [(3, 300), (1, 100), (2, 200)]
    first = values[0][1]
    c = interactive(f, lis=values)
    nt.assert_equal(len(c.children), 2)
    d = dict(
        cls=widgets.Dropdown,
        value=first,
        options=tuple(values),
        _options_labels=("3", "1", "2"),
        _options_values=(300, 100, 200),
    )
    check_widgets(c, lis=d) 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:15,代碼來源:test_interaction.py

示例15: test_ordereddict

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Dropdown [as 別名]
def test_ordereddict():
    from collections import OrderedDict
    items = [(3, 300), (1, 100), (2, 200)]
    first = items[0][1]
    values = OrderedDict(items)
    c = interactive(f, lis=values)
    nt.assert_equal(len(c.children), 2)
    d = dict(
        cls=widgets.Dropdown,
        value=first,
        options=values,
        _options_labels=("3", "1", "2"),
        _options_values=(300, 100, 200),
    )
    check_widgets(c, lis=d) 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:17,代碼來源:test_interaction.py


注:本文中的ipywidgets.Dropdown方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。