本文整理汇总了Python中ipywidgets.SelectMultiple方法的典型用法代码示例。如果您正苦于以下问题:Python ipywidgets.SelectMultiple方法的具体用法?Python ipywidgets.SelectMultiple怎么用?Python ipywidgets.SelectMultiple使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ipywidgets
的用法示例。
在下文中一共展示了ipywidgets.SelectMultiple方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import SelectMultiple [as 别名]
def __init__(self, mol):
super().__init__(mol)
self._atomset = collections.OrderedDict()
self.atom_listname = ipy.Label('Selected atoms:', layout=ipy.Layout(width='100%'))
self.atom_list = ipy.SelectMultiple(options=list(self.viewer.selected_atom_indices),
layout=ipy.Layout(height='150px'))
traitlets.directional_link(
(self.viewer, 'selected_atom_indices'),
(self.atom_list, 'options'),
self._atom_indices_to_atoms
)
self.select_all_atoms_button = ipy.Button(description='Select all atoms')
self.select_all_atoms_button.on_click(self.select_all_atoms)
self.select_none = ipy.Button(description='Clear all selections')
self.select_none.on_click(self.clear_selections)
self.representation_buttons = ipy.ToggleButtons(options=['stick','ribbon', 'auto', 'vdw'],
value='auto')
self.representation_buttons.observe(self._change_representation, 'value')
示例2: subscriber_ui
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import SelectMultiple [as 别名]
def subscriber_ui(self, labels):
"""
构建订阅的已添加的买入策略ui初始化
:param labels: list序列内部对象str用来描述解释
"""
# 添加针对指定买入策略的卖出策略
self.accordion = widgets.Accordion()
buy_factors_child = []
for label in labels:
buy_factors_child.append(widgets.Label(label,
layout=widgets.Layout(width='300px', align_items='stretch')))
self.buy_factors = widgets.SelectMultiple(
options=[],
description=u'已添加的买入策略:',
disabled=False,
layout=widgets.Layout(width='100%', align_items='stretch')
)
buy_factors_child.append(self.buy_factors)
buy_factors_box = widgets.VBox(buy_factors_child)
self.accordion.children = [buy_factors_box]
示例3: test_multiple_selection
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import SelectMultiple [as 别名]
def test_multiple_selection():
smw = widgets.SelectMultiple
# degenerate multiple select
w = smw()
check_widget(w, value=tuple())
# don't accept random other value when no options
with nt.assert_raises(TraitError):
w.value = (2,)
check_widget(w, value=tuple())
# basic multiple select
w = smw(options=[(1, 1)], value=[1])
check_widget(w, cls=smw, value=(1,), options=((1, 1),))
# don't accept random other value
with nt.assert_raises(TraitError):
w.value = w.value + (2,)
check_widget(w, value=(1,))
# change options, which resets value
w.options = w.options + ((2, 2),)
check_widget(w, options=((1, 1), (2,2)), value=())
# change value
w.value = (1,2)
check_widget(w, value=(1, 2))
# dict style
w.options = {1: 1}
check_widget(w, options={1:1})
# updating
with nt.assert_raises(TraitError):
w.value = (2,)
check_widget(w, options={1:1})
示例4: replay
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import SelectMultiple [as 别名]
def replay(cad_obj, index=0, debug=False, cad_width=600, height=600):
r = Replay(debug, cad_width, height)
if isinstance(cad_obj, cq.Workplane):
workplane = cad_obj
elif is_cqparts_part(cad_obj):
workplane = convert_cqparts(cad_obj, replay=True)
else:
print("Cannot replay", cad_obj)
return None
r.stack = r.format_steps(r.to_array(workplane, result_name=getattr(workplane, "name", None)))
r.indexes = [index]
r.select_box = SelectMultiple(
options=["[%02d] %s" % (i, code) for i, (code, obj) in enumerate(r.stack)],
index=r.indexes,
rows=len(r.stack),
description='',
disabled=False,
layout=Layout(width="600px"))
r.select_box.add_class("monospace")
r.select_box.observe(r.select_handler)
display(HBox([r.select_box, r.debug_output]))
r.select(r.indexes)
return r
#
# Control functions to enable, disable and reset replay
#
示例5: __init__
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import SelectMultiple [as 别名]
def __init__(self, show_add_buy=True, add_button_style='default'):
self.factor_dict = {}
self.factor_wg_array = []
# 策略候选池可x轴左右滚动
self.factor_layout = widgets.Layout(overflow_x='scroll',
# flex_direction='row',
display='flex')
self.selected_factors = widgets.SelectMultiple(
options=[],
description=u'已添加策略:',
disabled=False,
layout=widgets.Layout(width='100%', align_items='stretch')
)
# 已添加的全局策略可点击删除
self.selected_factors.observe(self.remove_factor, names='value')
# 全局策略改变通知接收序列
self.selected_factors_obs = set()
self.factor_box = None
# 默认不启动可滚动因子界面,因为对外的widget版本以及os操作系统不统一
self.scroll_factor_box = False
self._sub_children_group_cnt = 3
self.show_add_buy = show_add_buy
self.add_button_style = add_button_style
# 构建具体子类的界面构建
self._init_widget()
if self.factor_box is None:
raise RuntimeError('_init_widget must build factor_box!')
self.widget = widgets.VBox([self.factor_box, self.selected_factors])
示例6: _init_predict_ui
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import SelectMultiple [as 别名]
def _init_predict_ui(self):
"""裁判预测拦截界面初始化"""
description = widgets.Textarea(
value=u'裁判预测拦截:\n'
u'通过在\'裁判特征训练\'选中\'指定的裁判,选中的裁判将在对应的\n'
u'回测中生效,即开始在回测中对交易进行预测拦截等智能交易干涉行为',
disabled=False,
layout=widgets.Layout(height='150px')
)
# ump已选框
self.choice_umps = widgets.SelectMultiple(
description=u'已选裁判:',
disabled=False,
layout=widgets.Layout(width='100%', align_items='stretch')
)
self.choice_umps.observe(self.remove_ump_select, names='value')
self.umps = widgets.SelectMultiple(
description=u'备选裁判:',
disabled=False,
layout=widgets.Layout(width='100%', align_items='stretch')
)
self.umps.observe(self.on_ump_select, names='value')
self.load_train_ump(self.umps)
return widgets.VBox([description, self.choice_umps, self.umps])