本文整理汇总了Python中ipywidgets.IntSlider方法的典型用法代码示例。如果您正苦于以下问题:Python ipywidgets.IntSlider方法的具体用法?Python ipywidgets.IntSlider怎么用?Python ipywidgets.IntSlider使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ipywidgets
的用法示例。
在下文中一共展示了ipywidgets.IntSlider方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_single_value_int
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntSlider [as 别名]
def test_single_value_int():
for a in (1, 5, -3, 0):
if not a:
expected_min = 0
expected_max = 1
elif a > 0:
expected_min = -a
expected_max = 3*a
else:
expected_min = 3*a
expected_max = -a
c = interactive(f, a=a)
nt.assert_equal(len(c.children), 2)
w = c.children[0]
check_widget(w,
cls=widgets.IntSlider,
description='a',
value=a,
min=expected_min,
max=expected_max,
step=1,
readout=True,
)
示例2: test_defaults
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntSlider [as 别名]
def test_defaults():
@annotate(n=10)
def f(n, f=4.5, g=1):
pass
c = interactive(f)
check_widgets(c,
n=dict(
cls=widgets.IntSlider,
value=10,
),
f=dict(
cls=widgets.FloatSlider,
value=4.5,
),
g=dict(
cls=widgets.IntSlider,
value=1,
),
)
示例3: _widgets
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntSlider [as 别名]
def _widgets(self):
dfrange = self.varr.range('frame')
w_frame = iwgt.IntSlider(
value=0,
min=dfrange[0],
max=dfrange[1],
continuous_update=False,
description="Frame:")
w_paly = iwgt.Play(
value=0,
min=dfrange[0],
max=dfrange[1],
interval=1000 / self.framerate)
iwgt.jslink((w_paly, 'value'), (w_frame, 'value'))
iwgt.interactive(self.stream.event, f=w_frame)
return iwgt.HBox([w_paly, w_frame])
示例4: _widgets
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntSlider [as 别名]
def _widgets(self):
dfrange = self.ds.range('frame')
w_frame = iwgt.IntSlider(
value=0,
min=dfrange[0],
max=dfrange[1],
continuous_update=False,
description="Frame:")
w_paly = iwgt.Play(
value=0,
min=dfrange[0],
max=dfrange[1],
interval=1000 / self.framerate)
iwgt.jslink((w_paly, 'value'), (w_frame, 'value'))
iwgt.interactive(self.stream.event, f=w_frame)
return iwgt.HBox([w_paly, w_frame])
示例5: _init_widget
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntSlider [as 别名]
def _init_widget(self):
"""构建AbuFactorBuyBreak策略参数界面"""
self.description = widgets.Textarea(
value=u'海龟向上趋势突破买入策略:\n'
u'趋势突破定义为当天收盘价格超过N天内的最高价,超过最高价格作为买入信号买入股票持有',
description=u'海龟买入',
disabled=False,
layout=self.description_layout
)
self.xd_label = widgets.Label(u'突破周期参数:比如21,30,42天....突破', layout=self.label_layout)
self.xd = widgets.IntSlider(
value=21,
min=3,
max=120,
step=1,
description=u'周期',
disabled=False,
orientation='horizontal',
readout=True,
readout_format='d'
)
self.xd_box = widgets.VBox([self.xd_label, self.xd])
self.widget = widgets.VBox([self.description, self.xd_box, self.add], # border='solid 1px',
layout=self.widget_layout)
示例6: _pick_stock_base_ui
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntSlider [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])
示例7: interactive
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntSlider [as 别名]
def interactive( animation, size = 320 ):
basedir = mkdtemp()
basename = join( basedir, 'graph' )
steps = [ Image( path ) for path in render( animation.graphs(), basename, 'png', size ) ]
rmtree( basedir )
slider = widgets.IntSlider( min = 0, max = len( steps ) - 1, step = 1, value = 0 )
return widgets.interactive( lambda n: display(steps[ n ]), n = slider )
示例8: __init__
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntSlider [as 别名]
def __init__(self, gimbal, number, axes=range(3), min=-0x8000, max=0x7fff, step=1):
self.gimbal = gimbal
self.number = number
self.axes = axes
self.widgets = [None] * 3
ThreadToggle(self._update, description='Refresh param %02x' % number)
for t in self.axes:
v = self.gimbal.getParam(number=number, target=t)
self.widgets[t] = ipywidgets.IntSlider(description='Param %02x t=%d' % (self.number, t),
value=v, min=min, max=max, step=step,layout=dict(width='100%'))
ipywidgets.interact(self._set, x=self.widgets[t], target=ipywidgets.fixed(t))
示例9: plot_interactive
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntSlider [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,
)
示例10: _slice_base
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntSlider [as 别名]
def _slice_base(data: [np.ndarray], axis: int = -1, scale: int = 5, max_columns: int = None, colorbar: bool = False,
show_axes: bool = False, cmap: Union[Colormap, str] = 'gray', vlim: AxesParams = None,
callback: Callable = None, sliders: dict = None):
from ipywidgets import interact, IntSlider
check_shape_along_axis(*data, axis=axis)
vlim = np.broadcast_to(vlim, [len(data), 2]).tolist()
rows, columns = _get_rows_cols(max_columns, data)
sliders = sliders or {}
if 'idx' in sliders:
raise ValueError(f'Overriding "idx" is not allowed.')
def update(idx, **kwargs):
fig, axes = plt.subplots(rows, columns, figsize=(scale * columns, scale * rows))
for ax, x, (vmin, vmax) in zip(np.array(axes).flatten(), data, vlim):
im = ax.imshow(x.take(idx, axis=axis), cmap=cmap, vmin=vmin, vmax=vmax)
if colorbar:
fig.colorbar(im, ax=ax, orientation='horizontal')
if not show_axes:
ax.set_axis_off()
if callback is not None:
callback(axes, idx=idx, **kwargs)
plt.tight_layout()
plt.show()
interact(update, idx=IntSlider(min=0, max=data[0].shape[axis] - 1, continuous_update=False), **sliders)
示例11: interact
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntSlider [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_default_values
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntSlider [as 别名]
def test_default_values():
@annotate(n=10, f=(0, 10.), g=5, h=OrderedDict([('a',1), ('b',2)]), j=['hi', 'there'])
def f(n, f=4.5, g=1, h=2, j='there'):
pass
c = interactive(f)
check_widgets(c,
n=dict(
cls=widgets.IntSlider,
value=10,
),
f=dict(
cls=widgets.FloatSlider,
value=4.5,
),
g=dict(
cls=widgets.IntSlider,
value=5,
),
h=dict(
cls=widgets.Dropdown,
options=OrderedDict([('a',1), ('b',2)]),
value=2
),
j=dict(
cls=widgets.Dropdown,
options=('hi', 'there'),
value='there'
),
)
示例13: test_annotations
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntSlider [as 别名]
def test_annotations():
@annotate(n=10, f=widgets.FloatText())
def f(n, f):
pass
c = interactive(f)
check_widgets(c,
n=dict(
cls=widgets.IntSlider,
value=10,
),
f=dict(
cls=widgets.FloatText,
),
)
示例14: test_decorator_kwarg
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntSlider [as 别名]
def test_decorator_kwarg():
with patch.object(interaction, 'display', record_display):
@interact(a=5)
def foo(a):
pass
nt.assert_equal(len(displayed), 1)
w = displayed[0].children[0]
check_widget(w,
cls=widgets.IntSlider,
value=5,
)
示例15: test_call_interact_kwargs
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntSlider [as 别名]
def test_call_interact_kwargs():
def foo(a='default'):
pass
with patch.object(interaction, 'display', record_display):
ifoo = interact(foo, a=10)
nt.assert_equal(len(displayed), 1)
w = displayed[0].children[0]
check_widget(w,
cls=widgets.IntSlider,
value=10,
)