當前位置: 首頁>>代碼示例>>Python>>正文


Python ipywidgets.IntSlider方法代碼示例

本文整理匯總了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,
        ) 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:25,代碼來源:test_interaction.py

示例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,
        ),
    ) 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:22,代碼來源:test_interaction.py

示例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]) 
開發者ID:DeniseCaiLab,項目名稱:minian,代碼行數:18,代碼來源:visualization.py

示例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]) 
開發者ID:DeniseCaiLab,項目名稱:minian,代碼行數:18,代碼來源:visualization_ply.py

示例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) 
開發者ID:bbfamily,項目名稱:abu,代碼行數:27,代碼來源:ABuWGBuyFactor.py

示例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]) 
開發者ID:bbfamily,項目名稱:abu,代碼行數:27,代碼來源:ABuWGPSBase.py

示例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 ) 
開發者ID:mapio,項目名稱:GraphvizAnim,代碼行數:9,代碼來源:jupyter.py

示例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)) 
開發者ID:scanlime,項目名稱:fygimbal,代碼行數:15,代碼來源:fywidgets.py

示例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,
        ) 
開發者ID:kboone,項目名稱:avocado,代碼行數:38,代碼來源:dataset.py

示例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) 
開發者ID:neuro-ml,項目名稱:deep_pipe,代碼行數:29,代碼來源:visualize.py

示例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) 
開發者ID:scqubits,項目名稱:scqubits,代碼行數:40,代碼來源:explorer.py

示例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'
        ),
    ) 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:32,代碼來源:test_interaction.py

示例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,
        ),
    ) 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:17,代碼來源:test_interaction.py

示例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,
    ) 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:13,代碼來源:test_interaction.py

示例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,
    ) 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:13,代碼來源:test_interaction.py


注:本文中的ipywidgets.IntSlider方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。