当前位置: 首页>>代码示例>>Python>>正文


Python ipywidgets.jslink方法代码示例

本文整理汇总了Python中ipywidgets.jslink方法的典型用法代码示例。如果您正苦于以下问题:Python ipywidgets.jslink方法的具体用法?Python ipywidgets.jslink怎么用?Python ipywidgets.jslink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ipywidgets的用法示例。


在下文中一共展示了ipywidgets.jslink方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: controls_light

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import jslink [as 别名]
def controls_light(return_widget=False):
    fig = gcf()
    ambient_coefficient = ipywidgets.FloatSlider(
        min=0, max=1, step=0.001, value=fig.ambient_coefficient, description="ambient"
    )
    diffuse_coefficient = ipywidgets.FloatSlider(
        min=0, max=1, step=0.001, value=fig.diffuse_coefficient, description="diffuse"
    )
    specular_coefficient = ipywidgets.FloatSlider(
        min=0, max=1, step=0.001, value=fig.specular_coefficient, description="specular"
    )
    specular_exponent = ipywidgets.FloatSlider(
        min=0, max=10, step=0.001, value=fig.specular_exponent, description="specular exp"
    )
    ipywidgets.jslink((fig, 'ambient_coefficient'), (ambient_coefficient, 'value'))
    ipywidgets.jslink((fig, 'diffuse_coefficient'), (diffuse_coefficient, 'value'))
    ipywidgets.jslink((fig, 'specular_coefficient'), (specular_coefficient, 'value'))
    ipywidgets.jslink((fig, 'specular_exponent'), (specular_exponent, 'value'))
    widgets_bottom = [
        ipywidgets.HBox([ambient_coefficient, diffuse_coefficient]),
        ipywidgets.HBox([specular_coefficient, specular_exponent]),
    ]
    current.container.children += tuple(widgets_bottom)
    if return_widget:
        return widgets_bottom 
开发者ID:maartenbreddels,项目名称:ipyvolume,代码行数:27,代码来源:pylab.py

示例2: _widgets

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import jslink [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

示例3: _widgets

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import jslink [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

示例4: __init__

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import jslink [as 别名]
def __init__(self, inputs, targets, indexes=None, keyboard_shortcuts=True, save_hook=None):

        self.path = ''

        self.dirty_uindexes = set()

        self.save_hook = save_hook

        self.datamanager = DataManager(inputs, targets, indexes)

        slider = IntSlider(min=0, max=0)

        self.slider = slider

        self.prevbtn = Button(description='< Previous')
        self.nextbtn = Button(description='Next >')

        self.input_widgets = [dw.get_widget() for dw in self.datamanager.get_inputs()]
        self.target_widgets = [dw.get_widget() for dw in self.datamanager.get_targets()]

        self.add_class('innotater-base')

        cbar_widgets = [self.prevbtn, slider, self.nextbtn]
        if self.save_hook:
            self.savebtn = Button(description='Save', disabled=True)
            cbar_widgets.append(self.savebtn)

        controlbar_widget = HBox(cbar_widgets)
        controlbar_widget.add_class('innotater-controlbar')

        super().__init__([HBox([VBox(self.input_widgets), VBox(self.target_widgets)]),
                          controlbar_widget])

        widgets.jslink((slider, 'value'), (self, 'index'))

        self._observe_targets(self.datamanager.get_targets())

        for dw in list(self.datamanager.get_all()):
            dw.post_widget_create(self.datamanager)

        self.prevbtn.on_click(lambda c: self.move_slider(-1))
        self.nextbtn.on_click(lambda c: self.move_slider(1))

        if self.save_hook:
            self.savebtn.on_click(lambda c: self.save_hook_fire())

        self.slider.max = self.datamanager.get_data_len()-1

        self.index = 0
        self.keyboard_shortcuts = keyboard_shortcuts

        self.on_msg(self.handle_message)

        self.suspend_observed_changes = False
        self.update_ui() 
开发者ID:ideonate,项目名称:jupyter-innotater,代码行数:57,代码来源:innotaterwidget.py

示例5: show

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import jslink [as 别名]
def show(self, show_point_color=False):
        initial_point_size = 0.03
        point_materials = []
        for idx, (name, points) in enumerate(self.points.items()):
            if idx == 0:
                cloud = PyntCloud(points.get_points(show_point_color=show_point_color))
                #  print(clean_polylines(self.polylines))
                self.scene = cloud.plot(return_scene=True, initial_point_size=initial_point_size, polylines=clean_polylines(self.polylines), background=self.background)
                pss = [ps for ps in self.scene.children if type(ps) == pythreejs.objects.Points_autogen.Points]
                assert len(pss) > 0
                pss[0].name = name
                if points.opacity is not None:
                    pss[0].material.opacity = points.opacity
                    pss[0].material.transparent = True
                point_materials.append(pss[0].material)
            else:
                ppoints = get_points(points.points, points.color, show_point_color=show_point_color)
                ps = pyntcloud.plot.pythreejs_backend.get_pointcloud_pythreejs(ppoints[["x", "y", "z"]].values, ppoints[['red', 'green', 'blue']].values / 255.)
                ps.name = name
                ps.material.size = initial_point_size
                self.scene.children = [ps] + list(self.scene.children)
                if points.opacity is not None:
                    ps.material.opacity = points.opacity
                    ps.material.transparent = True
                #  if name == 'original':
                #      ps.material.opacity = 0.3
                #      ps.material.transparent = True
                point_materials.append(ps.material)

        for idx, (name, mesh) in enumerate(self.meshes.items()):
            # https://render.githubusercontent.com/view/ipynb?commit=645ea6bea758555978f83bd0004ce561fa58d99c&enc_url=68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6a7570797465722d776964676574732f707974687265656a732f363435656136626561373538353535393738663833626430303034636535363166613538643939632f6578616d706c65732f4578616d706c65732e6970796e62&nwo=jupyter-widgets%2Fpythreejs&path=examples%2FExamples.ipynb&repository_id=15400194&repository_type=Repository#Buffer-Geometries
            vertices = mesh.get_vertices()
            faces = mesh.get_faces()
            vertexcolors = ['#ff0000' for _ in range(len(vertices))]
            # Map the vertex colors into the 'color' slot of the faces
            faces = [f + [None, [vertexcolors[i] for i in f], None] for f in faces]
            geometry = pythreejs.Geometry(vertices=vertices, faces=faces, colors=vertexcolors)
            geometry.exec_three_obj_method('computeFaceNormals')
            mesh_obj = pythreejs.Mesh(geometry=geometry, material=pythreejs.MeshBasicMaterial(color='white', side='DoubleSide'), position=[0, 0, 0])
            mesh_obj.name = name
            self.scene.children = [mesh_obj] + list(self.scene.children)

        for key, value in self.visibility_dict.items():
            self.change_visibility(key, value)

        widgets = []
        size = ipywidgets.FloatSlider(value=initial_point_size, min=0.0, max=initial_point_size * 10, step=initial_point_size / 100)
        for point_materials in point_materials:
            ipywidgets.jslink((size, 'value'), (point_materials, 'size'))
        widgets.append(ipywidgets.Label('Point size:'))
        widgets.append(size)
        display(ipywidgets.HBox(children=widgets))


#  if __name__ == '__main__':
#      test() 
开发者ID:grossjohannes,项目名称:AlignNet-3D,代码行数:58,代码来源:pointcloud.py

示例6: figure

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import jslink [as 别名]
def figure(
    key=None,
    width=400,
    height=500,
    lighting=True,
    controls=True,
    controls_vr=False,
    controls_light=False,
    debug=False,
    **kwargs
):
    """Create a new figure if no key is given, or return the figure associated with key.

    :param key: Python object that identifies this figure
    :param int width: pixel width of WebGL canvas
    :param int height:  .. height ..
    :param bool lighting: use lighting or not
    :param bool controls: show controls or not
    :param bool controls_vr: show controls for VR or not
    :param bool debug: show debug buttons or not
    :return: :any:`Figure`
    """
    if key is not None and key in current.figures:
        current.figure = current.figures[key]
        current.container = current.containers[key]
    elif isinstance(key, ipv.Figure) and key in current.figures.values():
        key_index = list(current.figures.values()).index(key)
        key = list(current.figures.keys())[key_index]
        current.figure = current.figures[key]
        current.container = current.containers[key]
    else:
        current.figure = ipv.Figure(width=width, height=height, **kwargs)
        current.container = ipywidgets.VBox()
        current.container.children = [current.figure]
        if key is None:
            key = uuid.uuid4().hex
        current.figures[key] = current.figure
        current.containers[key] = current.container
        if controls:
            # stereo = ipywidgets.ToggleButton(value=current.figure.stereo, description='stereo', icon='eye')
            # l1 = ipywidgets.jslink((current.figure, 'stereo'), (stereo, 'value'))
            # current.container.children += (ipywidgets.HBox([stereo, ]),)
            pass  # stereo and fullscreen are now include in the js code (per view)
        if controls_vr:
            eye_separation = ipywidgets.FloatSlider(value=current.figure.eye_separation, min=-10, max=10, icon='eye')
            ipywidgets.jslink((eye_separation, 'value'), (current.figure, 'eye_separation'))
            current.container.children += (eye_separation,)
        if controls_light:
            globals()['controls_light']()
        if debug:
            show = ipywidgets.ToggleButtons(options=["Volume", "Back", "Front", "Coordinate"])
            current.container.children += (show,)
            # ipywidgets.jslink((current.figure, 'show'), (show, 'value'))
            traitlets.link((current.figure, 'show'), (show, 'value'))
    return current.figure 
开发者ID:maartenbreddels,项目名称:ipyvolume,代码行数:57,代码来源:pylab.py

示例7: animation_control

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import jslink [as 别名]
def animation_control(object, sequence_length=None, add=True, interval=200):
    """Animate scatter, quiver or mesh by adding a slider and play button.

    :param object: :any:`Scatter` or :any:`Mesh` object (having an sequence_index property), or a list of these to
                   control multiple.
    :param sequence_length: If sequence_length is None we try try our best to figure out, in case we do it badly,
            you can tell us what it should be. Should be equal to the S in the shape of the numpy arrays as for instance
            documented in :any:`scatter` or :any:`plot_mesh`.
    :param add: if True, add the widgets to the container, else return a HBox with the slider and play button. Useful when you
            want to customise the layout of the widgets yourself.
    :param interval: interval in msec between each frame
    :return: If add is False, if returns the ipywidgets.HBox object containing the controls
    """
    if isinstance(object, (list, tuple)):
        objects = object
    else:
        objects = [object]
    del object
    if sequence_length is None:
        # get all non-None arrays
        sequence_lengths = []
        for object in objects:
            sequence_lengths_previous = list(sequence_lengths)
            values = [getattr(object, name) for name in "x y z aux vx vy vz".split() if hasattr(object, name)]
            values = [k for k in values if k is not None]
            # sort them such that the higest dim is first
            values.sort(key=lambda key: -len(key.shape))
            try:
                sequence_length = values[0].shape[0]  # assume this defines the sequence length
                if isinstance(object, ipv.Mesh):  # for a mesh, it does not make sense to have less than 1 dimension
                    if len(values[0].shape) >= 2:  # if just 1d, it is most likely not an animation
                        sequence_lengths.append(sequence_length)
                else:
                    sequence_lengths.append(sequence_length)
            except IndexError:  # scalars get ignored
                pass
            if hasattr(object, 'color'):
                color = object.color
                if color is not None:
                    shape = color.shape
                    if len(shape) == 3:  # would be the case for for (frame, point_index, color_index)
                        sequence_lengths.append(shape[0])
                    # TODO: maybe support arrays of string type of form (frame, point_index)
            if len(sequence_lengths) == len(sequence_lengths_previous):
                raise ValueError('no frame dimension found for object: {}'.format(object))
        sequence_length = max(sequence_lengths)
    fig = gcf()
    fig.animation = interval
    fig.animation_exponent = 1.0
    play = ipywidgets.Play(min=0, max=sequence_length - 1, interval=interval, value=0, step=1)
    slider = ipywidgets.FloatSlider(min=0, max=play.max, step=1)
    ipywidgets.jslink((play, 'value'), (slider, 'value'))
    for object in objects:
        ipywidgets.jslink((slider, 'value'), (object, 'sequence_index'))
    control = ipywidgets.HBox([play, slider])
    if add:
        current.container.children += (control,)
    else:
        return control 
开发者ID:maartenbreddels,项目名称:ipyvolume,代码行数:61,代码来源:pylab.py


注:本文中的ipywidgets.jslink方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。