本文整理匯總了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])