Python ipywidgets 模块,IntSlider() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用ipywidgets.IntSlider()

项目:em_examples    作者:geoscixyz    | 项目源码 | 文件源码
def ImageUXOWidget():

    Out = interactive(fcnImageUXOWidget,psi=FloatSlider(min=-180., max=180., value=-0., step=10., continuous_update=False, description = "$\psi$"),\
            theta=FloatSlider(min=0, max=180., value=-0., step=10., continuous_update=False, description = "$\\theta$"),\
            phi=FloatSlider(min=-180., max=180., value=-0., step=10., continuous_update=False, description = "$\phi$"),\
            k1=FloatSlider(min=1., max=3., value=1., step=0.1, continuous_update=False, description = "$k_{x'}$"),\
            alpha1=FloatSlider(min=-4., max=-2., value=-3.7, step=0.1, continuous_update=False, description = "log($\\alpha_{x'}$)"),\
            beta1=FloatSlider(min=1., max=2., value=1., step=0.1, continuous_update=False, description = "$\\beta_{x'}$"),\
            gamma1=FloatSlider(min=-4., max=-2., value=-2.7, step=0.1, continuous_update=False, description = "log($\gamma_{x'}$)"),\
            k2=FloatSlider(min=1., max=3., value=1.5, step=0.1, continuous_update=False, description = "$k_{y'}$"),\
            alpha2=FloatSlider(min=-4., max=-2., value=-3.7, step=0.1, continuous_update=False, description = "log($\\alpha_{y'}$)"),\
            beta2=FloatSlider(min=1., max=2., value=-1., step=0.1, continuous_update=False, description = "$\\beta_{y'}$"),\
            gamma2=FloatSlider(min=-4., max=-2., value=-2.5, step=0.1, continuous_update=False, description = "log($\gamma_{y'}$)"),\
            k3=FloatSlider(min=1., max=3., value=2., step=0.1, continuous_update=False, description = "$k_{z'}$"),\
            alpha3=FloatSlider(min=-4., max=-2., value=-3.2, step=0.1, continuous_update=False, description = "log($\\alpha_{z'}$)"),\
            beta3=FloatSlider(min=1., max=2., value=1., step=0.1, continuous_update=False, description = "$\\beta_{z'}$"),\
            gamma3=FloatSlider(min=-4., max=-2., value=-2.2, step=0.1, continuous_update=False, description = "log($\gamma_{z'}$)"),\
            tn=IntSlider(min=1, max=11, value=1., step=1, continuous_update=False, description = "Time channel"))

    return Out
项目:yuuno    作者:Irrational-Encoding-Wizardry    | 项目源码 | 文件源码
def _default_ui_intslider(self):
        return IntSlider(
            continuous_update=False,
            orientation="horizontal",
            step=1,
            min=0,
            value=self.frame,
            max=1,
            layout=Layout(flex="2 2 auto")
        )
项目:fygimbal    作者:scanlime    | 项目源码 | 文件源码
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))
项目:fygimbal    作者:scanlime    | 项目源码 | 文件源码
def __init__(self, gimbal):
        self.gimbal = gimbal
        self.controlPacket = None

        xw = ipywidgets.IntSlider(value=0, min=-0x8000, max=0x7fff, step=1, layout=dict(width='100%'))
        yw = ipywidgets.IntSlider(value=0, min=-0x8000, max=0x7fff, step=1, layout=dict(width='100%'))
        zw = ipywidgets.IntSlider(value=0, min=-0x8000, max=0x7fff, step=1, layout=dict(width='100%'))
        mw = ipywidgets.IntSlider(value=1, min=0, max=255, step=1, layout=dict(width='100%'))
        ipywidgets.interact(self.setFn, x=xw, y=yw, z=zw, m=mw)

        ThreadToggle(self.loopFn, description='Controller thread')

        self.rate = ipywidgets.IntSlider(description='Update rate',
            value=25, min=1, max=400, step=1, layout=dict(width='100%'))
        display(self.rate)
项目:notebook-molecular-visualization    作者:Autodesk    | 项目源码 | 文件源码
def make_controls(self):
        self.playbutton = ipy.Play(value=0,
                                   min=0,
                                   max=self.traj.num_frames-1)

        self.slider = ipy.IntSlider(value_selects='framenum', value=0,
                                    description='Frame:', min=0, max=len(self.traj)-1,
                                    readout=False)
        self.readout = ipy.HTML(value='/%d' % (self.traj.num_frames - 1))
        self.annotation = ipy.HTML()

        traitlets.link((self.playbutton, 'value'), (self.slider, 'value'))
        traitlets.link((self.slider, 'value'), (self, 'current_frame'))
        return VBox((self.annotation,
                     HBox((self.playbutton, self.slider, self.readout))))
项目:snowballing    作者:JoaoFelipe    | 项目源码 | 文件源码
def slider(self, description, attribute, min, max, step, default, fn=None):
        """Creates slider"""
        widget = IntSlider(
            description=description,
            min=min,
            max=max,
            step=step,
            value=self._initial.get(attribute, default),
        )
        widget._configattr = attribute
        widget.observe(fn or self.update_widget, "value")
        return widget
项目:berrl    作者:murphy214    | 项目源码 | 文件源码
def assemble_widget_dicts(field,values,widget_type,dictlist):
    # if an empty dictionary is input for dictlist overwrites an empty list
    if dictlist == {}:
        dictlist = []

    # instantiating widget for integer slider
    if widget_type == 'IntSlider':
        minslider = widgets.IntSlider(description='Min ' + str(field),min=values[0],max=values[1],continuous_update=False)
        maxslider = widgets.IntSlider(description='Max ' + str(field),min=values[0],max=values[1],value=values[1],continuous_update=False)
        dictentry = {'type':'IntSlider','field':str(field),'widget':[minslider,maxslider]}
        dictlist.append(dictentry)
    # instantiating widget for float slider
    elif widget_type == 'FloatSlider':
        # getting significant figures of delta between min and maxx
        magnitude = determine_delta_magnitude([values[0],values[1]])

        # getting stepsize determined by the magnitude of difference
        # between min and max
        stepsize = 10 ** -(magnitude + 2)

        if stepsize < 10**-6:
             stepsize = 10 ** -6
        minvalue = round(values[0]-(.5*stepsize),magnitude+1)
        maxvalue = round(values[1]+(.5*stepsize),magnitude+1)

        # setting min and max slider
        minslider = widgets.FloatSlider(description='Min ' + str(field),min=minvalue,max=maxvalue,step=stepsize,value=minvalue,continuous_update=False)
        maxslider = widgets.FloatSlider(description='Max ' + str(field),min=minvalue,max=maxvalue,step=stepsize,value=maxvalue,continuous_update=False)

        # adding dictentry which will be updated to the widget dictlist
        dictentry = {'type':'FloatSlider','field':str(field),'widget':[minslider,maxslider]}
        dictlist.append(dictentry)
    elif widget_type == 'Dropdown':
        # given a list of unique categorical values returns widget with dropdown
        # for each value given
        print values
        dropdownwidget = widgets.Dropdown(description=str(field), options=values)
        dropdownwidget.padding = 4

        dictentry = {'type':'Dropdown','field':str(field),'widget':dropdownwidget}
        dictlist.append(dictentry)


    return dictlist

#assemble_widget_dicts('GEOHASH',['dnvfp6g'],'Dropdown',{})




# filters rows between a range and a field
# the range can contain either a float or an int
项目:berrl    作者:murphy214    | 项目源码 | 文件源码
def assemble_widget_dicts(field,values,widget_type,dictlist):
    # if an empty dictionary is input for dictlist overwrites an empty list
    if dictlist == {}:
        dictlist = []

    # instantiating widget for integer slider
    if widget_type == 'IntSlider':
        minslider = widgets.IntSlider(description='Min ' + str(field),min=values[0],max=values[1],continuous_update=False)
        maxslider = widgets.IntSlider(description='Max ' + str(field),min=values[0],max=values[1],value=values[1],continuous_update=False)
        dictentry = {'type':'IntSlider','field':str(field),'widget':[minslider,maxslider]}
        dictlist.append(dictentry)
    # instantiating widget for float slider
    elif widget_type == 'FloatSlider':
        # getting significant figures of delta between min and maxx
        magnitude = determine_delta_magnitude([values[0],values[1]])

        # getting stepsize determined by the magnitude of difference
        # between min and max
        stepsize = 10 ** -(magnitude + 2)

        if stepsize < 10**-6:
             stepsize = 10 ** -6
        minvalue = round(values[0]-(.5*stepsize),magnitude+1)
        maxvalue = round(values[1]+(.5*stepsize),magnitude+1)

        # setting min and max slider
        minslider = widgets.FloatSlider(description='Min ' + str(field),min=minvalue,max=maxvalue,step=stepsize,value=minvalue,continuous_update=False)
        maxslider = widgets.FloatSlider(description='Max ' + str(field),min=minvalue,max=maxvalue,step=stepsize,value=maxvalue,continuous_update=False)

        # adding dictentry which will be updated to the widget dictlist
        dictentry = {'type':'FloatSlider','field':str(field),'widget':[minslider,maxslider]}
        dictlist.append(dictentry)
    elif widget_type == 'Dropdown':
        # given a list of unique categorical values returns widget with dropdown
        # for each value given
        print values
        dropdownwidget = widgets.Dropdown(description=str(field), options=values)
        dropdownwidget.padding = 4

        dictentry = {'type':'Dropdown','field':str(field),'widget':dropdownwidget}
        dictlist.append(dictentry)


    return dictlist

#assemble_widget_dicts('GEOHASH',['dnvfp6g'],'Dropdown',{})




# filters rows between a range and a field
# the range can contain either a float or an int