本文整理汇总了Python中ipywidgets.Checkbox方法的典型用法代码示例。如果您正苦于以下问题:Python ipywidgets.Checkbox方法的具体用法?Python ipywidgets.Checkbox怎么用?Python ipywidgets.Checkbox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ipywidgets
的用法示例。
在下文中一共展示了ipywidgets.Checkbox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _pick_stock_base_ui
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Checkbox [as 别名]
def _pick_stock_base_ui(self):
"""选股策略中通用ui: xd, reversed初始构建"""
xd_tip = widgets.Label(u'设置选股策略生效周期,默认252天',
layout=widgets.Layout(width='300px', align_items='stretch'))
self.xd = widgets.IntSlider(
value=252,
min=1,
max=252,
step=1,
description=u'周期',
disabled=False,
orientation='horizontal',
readout=True,
readout_format='d'
)
self.xd_box = widgets.VBox([xd_tip, self.xd])
reversed_tip = widgets.Label(u'反转选股结果,默认不反转',
layout=widgets.Layout(width='300px', align_items='stretch'))
self.reversed = widgets.Checkbox(
value=False,
description=u'反转结果',
disabled=False,
)
self.reversed_box = widgets.VBox([reversed_tip, self.reversed])
示例2: _create_widget
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Checkbox [as 别名]
def _create_widget(self):
return Checkbox(description=self.desc, layout=self.layout, disabled=self.disabled)
示例3: calc_row_options
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Checkbox [as 别名]
def calc_row_options(self):
'''Widgets for canopy in rows'''
self.w_row = widgets.Checkbox(
description='Canopy in rows?', value=self.row)
self.w_rowaz = widgets.BoundedFloatText(
value=self.row_az,
min=0,
max=360,
description='Row orientation',
width=80)
self.w_rowaz.visible = False
示例4: test_single_value_bool
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Checkbox [as 别名]
def test_single_value_bool():
for a in (True, False):
c = interactive(f, a=a)
w = c.children[0]
check_widget(w,
cls=widgets.Checkbox,
description='a',
value=a,
)
示例5: _controllers_for
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Checkbox [as 别名]
def _controllers_for(opt):
"""
Give a string representing the parameter represented, find the appropriate
command.
"""
colors = [None, "blue", "red", "green", "black"]
controllers = {
"type": widgets.Dropdown(
options=["auto detect"] + _get_types(), description="type"
),
"bin": widgets.Checkbox(description="bin"),
"aggregate": widgets.Dropdown(
options=[None] + _get_functions(), description="aggregate"
),
"zero": widgets.Checkbox(description="zero"),
"text": widgets.Text(description="text value"),
"scale": widgets.Dropdown(options=["linear", "log"], description="scale"),
"color": widgets.Dropdown(options=colors, description="main color"),
"applyColorToBackground": widgets.Checkbox(
description="applyColorToBackground"
),
"shortTimeLabels": widgets.Checkbox(description="shortTimeLabels"),
}
for title, controller in controllers.items():
controller.title = title
if "Checkbox" in str(controller):
# traits = dir(controller.layout)
# traits = [t for t in traits if t[0] != '_']
controller.layout.max_width = "200ex"
# controller.layout.min_width = '100ex'
# controller.layout.width = '150ex'
return controllers[opt]
示例6: crop_recording_window
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Checkbox [as 别名]
def crop_recording_window(self):
self._sample.mspec.spec_stop()
self._sample.mspec.set_averages(1e4)
self._sample.mspec.set_window(0,512)
self._sample.mspec.set_segments(1)
msp = self._sample.mspec.acquire()
def pltfunc(start,end,done):
if done:
self._sample.acqu_window = [start,end]
self._sample.mspec.set_window(start,end)
self._sw.disabled = True
self._ew.disabled = True
self._dw.disabled = True
self._dw.description = "acqu_window set to [{:d}:{:d}]".format(start,end)
else:
plt.figure(figsize=(15,5))
plt.plot(msp)
plt.axvspan(0,start,color='k',alpha=.2)
plt.axvspan(end,len(msp),color='k',alpha=.2)
plt.xlim(0,len(msp))
plt.show()
self._sw = widgets.IntSlider(min=0,max=len(msp),step=1,value=self._sample.acqu_window[0],continuous_update=True)
self._ew = widgets.IntSlider(min=0,max=len(msp),step=1,value=self._sample.acqu_window[1],continuous_update=True)
self._dw = widgets.Checkbox(value=False,description="Done!",indent=True)
self._wgt = widgets.interact(pltfunc,start=self._sw,end=self._ew,done=self._dw)
self._sample.mspec.set_window(*self._sample.acqu_window)
示例7: create_checkbox
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Checkbox [as 别名]
def create_checkbox(self, kind, description, value, handler):
checkbox = Checkbox(value=value, description=description, indent=False)
checkbox.observe(handler, "value")
checkbox.add_class("view_%s" % kind)
return checkbox
示例8: _widget
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Checkbox [as 别名]
def _widget(self):
import ipywidgets
return ipywidgets.Checkbox(value=self.value, indent=False)
示例9: __init__
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Checkbox [as 别名]
def __init__(self):
self.client = None
self.warning = ipy.HTML(description='<b>Engine status:</b>', value=SPINNER)
self.devmode_label = ipy.Label('Use local docker images (developer mode)',
layout=ipy.Layout(width='100%'))
self.devmode_button = ipy.Checkbox(value=mdt.compute.config.devmode,
layout=ipy.Layout(width='15px'))
self.devmode_button.observe(self.set_devmode, 'value')
self.engine_config_description = ipy.HTML('Docker host with protocol and port'
' (e.g., <code>http://localhost:2375</code>).'
' If blank, this'
' defaults to the docker engine configured at '
'your command line.',
layout=ipy.Layout(width='100%'))
self.engine_config_value = ipy.Text('blank', layout=ipy.Layout(width='100%'))
self.engine_config_value.add_class('nbv-monospace')
self.image_box = ipy.Box()
self._reset_config_button = ipy.Button(description='Reset',
tooltip='Reset to applied value')
self._apply_changes_button = ipy.Button(description='Apply',
tooltip='Apply for this session')
self._save_changes_button = ipy.Button(description='Make default',
tooltip='Make this the default for new sessions')
self._reset_config_button.on_click(self.reset_config)
self._apply_changes_button.on_click(self.apply_config)
self._save_changes_button.on_click(self.save_config)
self.children = [self.warning,
VBox([self.engine_config_description,
self.engine_config_value]),
HBox([self._reset_config_button,
self._apply_changes_button,
self._save_changes_button]),
HBox([self.devmode_button, self.devmode_label]),
self.image_box]
self.reset_config()
super().__init__(children=self.children)
self.connect_to_engine()
示例10: _widgets
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Checkbox [as 别名]
def _widgets(self):
dfrange = [0, self._f]
w_frame = iwgt.IntSlider(
value=0,
min=dfrange[0],
max=dfrange[1],
continuous_update=False,
description="Frame:",
layout=iwgt.Layout(width='50%'))
w_play = iwgt.Play(
value=0,
min=dfrange[0],
max=dfrange[1],
interval=1000 / self.framerate)
iwgt.jslink((w_play, 'value'), (w_frame, 'value'))
iwgt.interactive(self.strm_f.event, x=w_frame)
uidrange = [0, self._u]
w_select = iwgt.IntRangeSlider(
value=self._cur_sel,
min=uidrange[0],
max=uidrange[1],
continuous_update=False,
description="Unit ID:",
layout=iwgt.Layout(width='50%'))
w_select.observe(self._set_sel, names='value')
w_update = iwgt.Button(description="Update")
w_update.on_click(self._update_plot)
w_update_mov = iwgt.Checkbox(
value=self._update_mov, description="Update Movies")
w_update_mov.observe(self._set_update, names='value')
w_overlay = iwgt.Checkbox(value=self._overlay, description="Overlay")
w_overlay.observe(self._set_overlay, names='value')
return iwgt.VBox([
iwgt.HBox([w_frame, w_play, w_update_mov]),
iwgt.HBox([w_select, w_update, w_overlay])
])
示例11: _spatial_all_wgt
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Checkbox [as 别名]
def _spatial_all_wgt(self):
wgt_useAC = pnwgt.Checkbox(
name='UseAC', value=self._useAC, width=120, height=15)
def callback_useAC(val):
self._useAC = val.new
self.update_AC()
wgt_useAC.param.watch(callback_useAC, 'value')
return pn.layout.WidgetBox(wgt_useAC, width=150)
示例12: init_distances_ui
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Checkbox [as 别名]
def init_distances_ui(self):
"""距离分析ui"""
with self._init_widget_list_action(self.distances_analyse, u'距离分析', -1) as widget_list:
self.distances_mode = widgets.RadioButtons(
options={u'曼哈顿距离(L1范数)': 0, u'欧式距离(L2范数)': 1, u'余弦距离': 2},
value=0,
description=u'距离模式:',
disabled=False
)
widget_list.append(self.distances_mode)
scale_end_label = widgets.Label(u'对结果矩阵进行标准化处理', layout=self.label_layout)
self.scale_end = widgets.Checkbox(
value=True,
description=u'标准化',
disabled=False
)
scale_end_box = widgets.VBox([scale_end_label, self.scale_end])
widget_list.append(scale_end_box)
similar_tip_label = widgets.Label(u'对结果矩阵进行转换相关性', layout=self.label_layout)
self.to_similar = widgets.Checkbox(
value=False,
description=u'转换相关',
disabled=False
)
to_similar_box = widgets.VBox([similar_tip_label, self.to_similar])
widget_list.append(to_similar_box)
return widgets.VBox(widget_list, # border='solid 1px',
layout=self.tool_layout)
示例13: create_settings
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Checkbox [as 别名]
def create_settings(box):
"Creates a widget Container for settings and info of a particular slider."
_, slider, sl_units = box.children
enable = widgets.Checkbox(value=box.visible, width="3ex")
link((box, 'visible'), (enable, 'value'))
def slider_link(obj, attr):
"Function to link one object to an attr of the slider."
# pylint: disable=unused-argument
def link_fn(name, new_value):
"How to update the object's value given min/max on the slider. "
if new_value >= slider.max:
slider.max = new_value
# if any value is greater than the max, the max slides up
# however, this is not held true for the minimum, because
# during typing the max or value will grow, and we don't want
# to permanently anchor the minimum to unfinished typing
if attr == "max" and new_value <= slider.value:
if slider.max >= slider.min:
slider.value = new_value
else:
pass # bounds nonsensical, probably because we picked up
# a small value during user typing.
elif attr == "min" and new_value >= slider.value:
slider.value = new_value
setattr(slider, attr, new_value)
slider.step = (slider.max - slider.min)/24.0
obj.on_trait_change(link_fn, "value")
link((slider, attr), (obj, "value"))
text_html = "<span class='form-control' style='width: auto;'>"
setvalue = widgets.FloatText(value=slider.value,
description=slider.description)
slider_link(setvalue, "value")
fromlabel = widgets.HTML(text_html + "from")
setmin = widgets.FloatText(value=slider.min, width="10ex")
slider_link(setmin, "min")
tolabel = widgets.HTML(text_html + "to")
setmax = widgets.FloatText(value=slider.max, width="10ex")
slider_link(setmax, "max")
units = widgets.Label()
units.width = "6ex"
units.font_size = "1.165em"
link((sl_units, 'value'), (units, 'value'))
descr = widgets.HTML(text_html + slider.varkey.descr.get("label", ""))
descr.width = "40ex"
return widgets.HBox(children=[enable, setvalue, units, descr,
fromlabel, setmin, tolabel, setmax],
width="105ex")
示例14: __init__
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Checkbox [as 别名]
def __init__(
self,
env_var: str,
help_str: str = None,
prompt: str = "Enter the value: ",
auto_display: bool = False,
):
"""
Create a new instance of GetEnvironmentKey.
Parameters
----------
env_var : str
Name of the environment variable.
help_str : str, optional
Help to display if the environment variable is not set. (the default is None)
prompt : str, optional
Prompt to display with the text box.
(the default is "Enter the value: ")
auto_display : bool, optional
Whether to display on instantiation (the default is False)
"""
self._value = os.environ.get(env_var)
self._name = env_var
if not self._value:
display(widgets.HTML(value=help_str))
self._w_text = widgets.Text(
value=self._value,
description=prompt,
layout=Layout(width="50%"),
style={"description_width": "initial"},
)
self._w_save_button = widgets.Button(
description="Set",
layout=Layout(width="10%", disabled=False),
style={"description_width": "initial"},
)
self._w_check_save = widgets.Checkbox(
value=True, description="Save as environment var", disabled=False
)
self._w_save_button.on_click(self._on_save_button_clicked)
self._hbox = widgets.HBox(
[self._w_text, self._w_save_button, self._w_check_save]
)
if auto_display:
self.display()
示例15: _man_wgt
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Checkbox [as 别名]
def _man_wgt(self):
usub = self.strm_usub.usub
usub.sort()
usub.reverse()
ulabs = self.unit_labels.sel(unit_id=usub).values
wgt_sel = {uid: pnwgt.Select(
name='Unit Label', options=usub+[-1]+ulabs.tolist(),
value=ulb, height=50, width=100) for uid, ulb in zip(usub, ulabs)}
def callback_ulab(value, uid):
self.unit_labels.loc[uid] = value.new
for uid, sel in wgt_sel.items():
cb = fct.partial(callback_ulab, uid=uid)
sel.param.watch(cb, 'value')
wgt_check = {uid: pnwgt.Checkbox(
name='Unit ID: {}'.format(uid), value=False,
height=50, width=100) for uid in usub}
def callback_chk(val, uid):
if not val.old == val.new:
if val.new:
self.usub_sel.append(uid)
else:
self.usub_sel.remove(uid)
for uid, chk in wgt_check.items():
cb = fct.partial(callback_chk, uid=uid)
chk.param.watch(cb, 'value')
wgt_discard = pnwgt.Button(
name='Discard Selected',
button_type='primary', width=200)
def callback_discard(clicks):
for uid in self.usub_sel:
wgt_sel[uid].value = -1
wgt_discard.param.watch(callback_discard, 'clicks')
wgt_merge = pnwgt.Button(
name='Merge Selected',
button_type='primary', width=200)
def callback_merge(clicks):
for uid in self.usub_sel:
wgt_sel[uid].value = self.usub_sel[0]
wgt_merge.param.watch(callback_merge, 'clicks')
return pn.layout.Column(
pn.layout.WidgetBox(wgt_discard, wgt_merge, width=200),
pn.layout.Row(
pn.layout.WidgetBox(*wgt_check.values(), width=100),
pn.layout.WidgetBox(*wgt_sel.values(), width=100)))