ipyvtklink


Nameipyvtklink JSON
Version 0.2.3 PyPI version JSON
download
home_pagehttps://github.com/Kitware/ipyvtklink
Summaryipywidget for vtkRenderWindow
upload_time2022-09-27 16:17:19
maintainer
docs_urlNone
authorBane Sullivan
requires_python>=3.5.*
licenseBSD 3-Clause
keywords vtk plotting jupyter
VCS
bugtrack_url
requirements ipycanvas ipyevents ipywidgets
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ipyvtklink

[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Kitware/ipyvtklink/master)
[![PyPI](https://img.shields.io/pypi/v/ipyvtklink.svg?logo=python&logoColor=white)](https://pypi.org/project/ipyvtklink/)
[![conda](https://img.shields.io/conda/vn/conda-forge/ipyvtklink.svg?logo=conda-forge&logoColor=white)](https://anaconda.org/conda-forge/ipyvtklink)

*An ipywidget for vtkRenderWindow* (formerly `ipyvtk-simple`)

This is an early prototype of creating a Jupyter interface to VTK. This toolkit
is a proof of concept and a more polished tool will be available as
[`ipyvtk`](https://github.com/Kitware/ipyvtk) in the future.

The code here was implemented from the work done by [Andras Lasso](https://github.com/lassoan)
under an MIT License (see [the source](https://github.com/Slicer/SlicerJupyter/blob/master/JupyterNotebooks/JupyterNotebooksLib/interactive_view_widget.py)).

The goal is to enable this widget to work with any server side
[`vtkRenderWindow`](https://vtk.org/doc/nightly/html/classvtkRenderWindow.html)
This render window could be from [VTK Python](https://vtk.org/),
[ParaView](https://www.paraview.org/), or [PyVista](https://www.pyvista.org/).

Please note that `vtk` is not listed as a requirement for this package to
simplify its installation in virtual environments where VTK may be built from
source or bundled with ParaView and we do not want to install the wheels from
PyPI.

## Installation

For use with PyVista, simply install with `pip` or `conda`:

```
pip install ipyvtklink
```

or
```
conda install -c conda-forge ipyvtklink
```

## Run in Docker

A Docker image is prebuilt and hosted in the ipyvtklink repository's packages.

To run in Docker:

```
docker pull ghcr.io/kitware/ipyvtklink:latest
docker run -p 8888:8888 ghcr.io/kitware/ipyvtklink:latest
```

and open the `vtk.ipynb` notebook.

Additionally, this can be used with ParaView. An example is given in
`paraview.ipynb` which can be run via:

```
docker pull ghcr.io/kitware/ipyvtklink-paraview:latest
docker run -p 8878:8878 ghcr.io/kitware/ipyvtklink-paraview:latest
```

## Examples

You may have to build jupyter lab extensions for this to work in Lab. This is
known to work well in Notebook.


### PyVista

PyVista has fully implemented downstream support for `ipyvtklink`. See [PyVista's Documentation](https://docs.pyvista.org/user-guide/jupyter/ipyvtk_plotting.html)

See the `pyvista.ipynb` for an original proof of concept.

![demo-1](https://raw.githubusercontent.com/Kitware/ipyvtklink/master/assets/demo-1.gif)

![demo-2](https://raw.githubusercontent.com/Kitware/ipyvtklink/master/assets/demo-2.gif)


### Python VTK

The widget here can be used with VTK. Here is a minimal example showing how
to pass any `vtkRenderWindow` to the `ViewInteractiveWidget`:

```py
import vtk
from ipyvtklink.viewer import ViewInteractiveWidget

# Create some data
cylinder = vtk.vtkCylinderSource()
cylinder.SetResolution(8)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(cylinder.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)

# Set up render window
ren = vtk.vtkRenderer()
ren_win = vtk.vtkRenderWindow()
ren_win.SetOffScreenRendering(1)
ren_win.SetSize(600, 600)
ren_win.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(ren_win)
style = vtk.vtkInteractorStyleTrackballCamera()
iren.SetInteractorStyle(style)

# Add actor to scene
ren.AddActor(actor)
ren.ResetCamera()

# Display
ViewInteractiveWidget(ren_win)
```

![demo-3](https://raw.githubusercontent.com/Kitware/ipyvtklink/master/assets/demo-3.gif)


### ParaView Python

See instructions above for running ParaView in a Docker container.

```py
import paraview.simple as pvs
from ipyvtklink.viewer import ViewInteractiveWidget

# Create data on the pipeline
wavelet = pvs.Wavelet()
contour = pvs.Contour(Input=wavelet)
contour.ContourBy = ['POINTS', 'RTData']
contour.Isosurfaces = [63, 143, 170, 197, 276]

# Set the data as visible
pvs.Show(contour)

# Fetch the view and render the scene
view = pvs.GetActiveView()
pvs.Render(view)

# Fetch the RenderWindow
ren_win = view.GetClientSideObject().GetRenderWindow()
# Display the RenderWindow with the widget
ViewInteractiveWidget(ren_win)
```

![demo-4](https://raw.githubusercontent.com/Kitware/ipyvtklink/master/assets/demo-4.gif)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Kitware/ipyvtklink",
    "name": "ipyvtklink",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5.*",
    "maintainer_email": "",
    "keywords": "vtk plotting jupyter",
    "author": "Bane Sullivan",
    "author_email": "bane.sullivan@kitware.com",
    "download_url": "https://files.pythonhosted.org/packages/d6/e6/4771ca4dd69e933af9ab1308efafaf797ebc0ef0626ee5615ea9e8e2665b/ipyvtklink-0.2.3.tar.gz",
    "platform": null,
    "description": "# ipyvtklink\n\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Kitware/ipyvtklink/master)\n[![PyPI](https://img.shields.io/pypi/v/ipyvtklink.svg?logo=python&logoColor=white)](https://pypi.org/project/ipyvtklink/)\n[![conda](https://img.shields.io/conda/vn/conda-forge/ipyvtklink.svg?logo=conda-forge&logoColor=white)](https://anaconda.org/conda-forge/ipyvtklink)\n\n*An ipywidget for vtkRenderWindow* (formerly `ipyvtk-simple`)\n\nThis is an early prototype of creating a Jupyter interface to VTK. This toolkit\nis a proof of concept and a more polished tool will be available as\n[`ipyvtk`](https://github.com/Kitware/ipyvtk) in the future.\n\nThe code here was implemented from the work done by [Andras Lasso](https://github.com/lassoan)\nunder an MIT License (see [the source](https://github.com/Slicer/SlicerJupyter/blob/master/JupyterNotebooks/JupyterNotebooksLib/interactive_view_widget.py)).\n\nThe goal is to enable this widget to work with any server side\n[`vtkRenderWindow`](https://vtk.org/doc/nightly/html/classvtkRenderWindow.html)\nThis render window could be from [VTK Python](https://vtk.org/),\n[ParaView](https://www.paraview.org/), or [PyVista](https://www.pyvista.org/).\n\nPlease note that `vtk` is not listed as a requirement for this package to\nsimplify its installation in virtual environments where VTK may be built from\nsource or bundled with ParaView and we do not want to install the wheels from\nPyPI.\n\n## Installation\n\nFor use with PyVista, simply install with `pip` or `conda`:\n\n```\npip install ipyvtklink\n```\n\nor\n```\nconda install -c conda-forge ipyvtklink\n```\n\n## Run in Docker\n\nA Docker image is prebuilt and hosted in the ipyvtklink repository's packages.\n\nTo run in Docker:\n\n```\ndocker pull ghcr.io/kitware/ipyvtklink:latest\ndocker run -p 8888:8888 ghcr.io/kitware/ipyvtklink:latest\n```\n\nand open the `vtk.ipynb` notebook.\n\nAdditionally, this can be used with ParaView. An example is given in\n`paraview.ipynb` which can be run via:\n\n```\ndocker pull ghcr.io/kitware/ipyvtklink-paraview:latest\ndocker run -p 8878:8878 ghcr.io/kitware/ipyvtklink-paraview:latest\n```\n\n## Examples\n\nYou may have to build jupyter lab extensions for this to work in Lab. This is\nknown to work well in Notebook.\n\n\n### PyVista\n\nPyVista has fully implemented downstream support for `ipyvtklink`. See [PyVista's Documentation](https://docs.pyvista.org/user-guide/jupyter/ipyvtk_plotting.html)\n\nSee the `pyvista.ipynb` for an original proof of concept.\n\n![demo-1](https://raw.githubusercontent.com/Kitware/ipyvtklink/master/assets/demo-1.gif)\n\n![demo-2](https://raw.githubusercontent.com/Kitware/ipyvtklink/master/assets/demo-2.gif)\n\n\n### Python VTK\n\nThe widget here can be used with VTK. Here is a minimal example showing how\nto pass any `vtkRenderWindow` to the `ViewInteractiveWidget`:\n\n```py\nimport vtk\nfrom ipyvtklink.viewer import ViewInteractiveWidget\n\n# Create some data\ncylinder = vtk.vtkCylinderSource()\ncylinder.SetResolution(8)\nmapper = vtk.vtkPolyDataMapper()\nmapper.SetInputConnection(cylinder.GetOutputPort())\nactor = vtk.vtkActor()\nactor.SetMapper(mapper)\n\n# Set up render window\nren = vtk.vtkRenderer()\nren_win = vtk.vtkRenderWindow()\nren_win.SetOffScreenRendering(1)\nren_win.SetSize(600, 600)\nren_win.AddRenderer(ren)\niren = vtk.vtkRenderWindowInteractor()\niren.SetRenderWindow(ren_win)\nstyle = vtk.vtkInteractorStyleTrackballCamera()\niren.SetInteractorStyle(style)\n\n# Add actor to scene\nren.AddActor(actor)\nren.ResetCamera()\n\n# Display\nViewInteractiveWidget(ren_win)\n```\n\n![demo-3](https://raw.githubusercontent.com/Kitware/ipyvtklink/master/assets/demo-3.gif)\n\n\n### ParaView Python\n\nSee instructions above for running ParaView in a Docker container.\n\n```py\nimport paraview.simple as pvs\nfrom ipyvtklink.viewer import ViewInteractiveWidget\n\n# Create data on the pipeline\nwavelet = pvs.Wavelet()\ncontour = pvs.Contour(Input=wavelet)\ncontour.ContourBy = ['POINTS', 'RTData']\ncontour.Isosurfaces = [63, 143, 170, 197, 276]\n\n# Set the data as visible\npvs.Show(contour)\n\n# Fetch the view and render the scene\nview = pvs.GetActiveView()\npvs.Render(view)\n\n# Fetch the RenderWindow\nren_win = view.GetClientSideObject().GetRenderWindow()\n# Display the RenderWindow with the widget\nViewInteractiveWidget(ren_win)\n```\n\n![demo-4](https://raw.githubusercontent.com/Kitware/ipyvtklink/master/assets/demo-4.gif)\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause",
    "summary": "ipywidget for vtkRenderWindow",
    "version": "0.2.3",
    "split_keywords": [
        "vtk",
        "plotting",
        "jupyter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "e8f78e62d9f00ef7a3dbb529d320acfa",
                "sha256": "2d310a24bd130e077c346ff6ab0991f236794e1d76a1fff5edda92e5e758a143"
            },
            "downloads": -1,
            "filename": "ipyvtklink-0.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e8f78e62d9f00ef7a3dbb529d320acfa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5.*",
            "size": 9355,
            "upload_time": "2022-09-27T16:17:17",
            "upload_time_iso_8601": "2022-09-27T16:17:17.337763Z",
            "url": "https://files.pythonhosted.org/packages/ff/8c/8cbca6af19e6aeabd66e45b86b02bc22b845defa8f63066165adc58b429a/ipyvtklink-0.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "85b060fc9cdccab75f6aa6e8f09574b3",
                "sha256": "7e5a8d0b0b4da9ae5db96618a8ed6ecdbe7b83b0c79b9b52c998129b35da825d"
            },
            "downloads": -1,
            "filename": "ipyvtklink-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "85b060fc9cdccab75f6aa6e8f09574b3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5.*",
            "size": 10474,
            "upload_time": "2022-09-27T16:17:19",
            "upload_time_iso_8601": "2022-09-27T16:17:19.514464Z",
            "url": "https://files.pythonhosted.org/packages/d6/e6/4771ca4dd69e933af9ab1308efafaf797ebc0ef0626ee5615ea9e8e2665b/ipyvtklink-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-09-27 16:17:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Kitware",
    "github_project": "ipyvtklink",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "ipycanvas",
            "specs": [
                [
                    ">=",
                    "0.5.0"
                ]
            ]
        },
        {
            "name": "ipyevents",
            "specs": [
                [
                    ">=",
                    "0.8.0"
                ]
            ]
        },
        {
            "name": "ipywidgets",
            "specs": [
                [
                    "~=",
                    "7.7"
                ]
            ]
        }
    ],
    "lcname": "ipyvtklink"
}
        
Elapsed time: 0.01644s