本文整理汇总了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)
示例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',
),
)
示例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);
示例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)
示例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]
示例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])
示例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)
示例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)
示例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
示例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,
)
示例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)
示例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)
示例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)
示例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)
示例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)