# vtk-js remoteview example get any widget interaction

**URL:** https://discourse.vtk.org/t/vtk-js-remoteview-example-get-any-widget-interaction/6157
**Category:** Web
**Created:** [July 9, 2021, 7:55am UTC](https://discourse.vtk.org/t/vtk-js-remoteview-example-get-any-widget-interaction/6157 "2021-07-09T07:55:06Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![ss59](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ss59/32/3666_2.png) [@ss59](https://discourse.vtk.org/u/ss59)
#### Post date: [July 9, 2021, 7:55am UTC](https://discourse.vtk.org/t/vtk-js-remoteview-example-get-any-widget-interaction/6157/1 "2021-07-09T07:55:06Z")

</div>

Hello, Sorry about my simple question. I was testing remoteview using exist example. (vtk\_server.py). I added a simple vtkBoxWidget. After I couldn’t any interaction on remoteview or when I interact window the session crashed. How can I interact with this widget on remoteview. Please help me and give me suggestions.

I used the link [https://kitware.github.io/vtk-js/examples/RemoteView.html](https://kitware.github.io/vtk-js/examples/RemoteView.html)  
boxWidget code is below,

```
        boxWidget = vtk.vtkBoxWidget()
        boxWidget.SetInteractor(renderWindowInteractor)
        boxWidget.SetProp3D(actor)
        boxWidget.SetPlaceFactor(1.25)  
        boxWidget.PlaceWidget()
        boxWidget.On()
```

---

<div class="post-metadata">

### Author: ![lambacini](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lambacini/32/3683_2.png) [@lambacini](https://discourse.vtk.org/u/lambacini)
#### Post date: [July 9, 2021, 12:46pm UTC](https://discourse.vtk.org/t/vtk-js-remoteview-example-get-any-widget-interaction/6157/2 "2021-07-09T12:46:40Z")

</div>

Can you define box widget as global (variable) and try ? Probably your problem will be solved.

---

<div class="post-metadata">

### Author: ![ss59](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ss59/32/3666_2.png) [@ss59](https://discourse.vtk.org/u/ss59)
#### Post date: [July 9, 2021, 12:58pm UTC](https://discourse.vtk.org/t/vtk-js-remoteview-example-get-any-widget-interaction/6157/3 "2021-07-09T12:58:53Z")

</div>

If you define in python initialize method any widgets. You can solve this problem. But I didn’t understand why we are defining it like this.  
why is that! I need to learn the reason.

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [July 9, 2021, 10:28pm UTC](https://discourse.vtk.org/t/vtk-js-remoteview-example-get-any-widget-interaction/6157/4 "2021-07-09T22:28:46Z")

</div>

Please share your code otherwise it is hard to tell where it was defined. Initialize method is only called onced and only when the server is ready. I’m not sure where you put your code before.

---

<div class="post-metadata">

### Author: ![ss59](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ss59/32/3666_2.png) [@ss59](https://discourse.vtk.org/u/ss59)
#### Post date: [July 12, 2021, 6:20am UTC](https://discourse.vtk.org/t/vtk-js-remoteview-example-get-any-widget-interaction/6157/5 "2021-07-12T06:20:32Z")

</div>

Hello, Thank u for your interest. If I write the box widget on initializing method its works. But it actually has to work like this, isn’t it?

```auto
class _WebCone(vtk_wslink.ServerProtocol):

    # Application configuration
    view = None
    authKey = "wslink-secret"

    def initialize(self):
        global renderer, renderWindow, renderWindowInteractor, cone, mapper, actor

        # Bring used components
        self.registerVtkWebProtocol(protocols.vtkWebMouseHandler())
        self.registerVtkWebProtocol(protocols.vtkWebViewPort())
        self.registerVtkWebProtocol(protocols.vtkWebPublishImageDelivery(decode=False))
        self.registerVtkWebProtocol(protocols.vtkWebViewPortGeometryDelivery())
        
        # Update authentication key to use
        self.updateSecret(_WebCone.authKey)

        # tell the C++ web app to use no encoding.
        # ParaViewWebPublishImageDelivery must be set to decode=False to match.
        self.getApplication().SetImageEncoding(0)

        # Create default pipeline (Only once for all the session)
        if not _WebCone.view:
            # VTK specific code
            renderer = vtk.vtkRenderer()
            renderWindow = vtk.vtkRenderWindow()
            renderWindow.AddRenderer(renderer)

            renderWindowInteractor = vtk.vtkRenderWindowInteractor()
            renderWindowInteractor.SetRenderWindow(renderWindow)
            renderWindowInteractor.GetInteractorStyle().SetCurrentStyleToTrackballCamera()

            cone = vtk.vtkConeSource()
            mapper = vtk.vtkPolyDataMapper()
            actor = vtk.vtkActor()

            mapper.SetInputConnection(cone.GetOutputPort())
            actor.SetMapper(mapper)
            renderer.AddActor(actor)
            
            boxWidget = vtk.vtkBoxWidget()
            boxWidget.SetInteractor(renderWindowInteractor)
            boxWidget.SetProp3D(actor)
            boxWidget.SetPlaceFactor(1.25)
            boxWidget.PlaceWidget()
            boxWidget.On()
            
            renderer.ResetCamera()
            renderWindow.Render()
           
            # VTK Web application specific
            _WebCone.view = renderWindow
            self.getApplication().GetObjectIdMap().SetActiveObject("VIEW", renderWindow)

```

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [July 27, 2021, 1:55am UTC](https://discourse.vtk.org/t/vtk-js-remoteview-example-get-any-widget-interaction/6157/6 "2021-07-27T01:55:04Z")

</div>

yes

---

<div class="post-metadata">

### Author: ![bernland](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/b19c9b/32.png) [@bernland](https://discourse.vtk.org/u/bernland)
#### Post date: [October 21, 2021, 3:36pm UTC](https://discourse.vtk.org/t/vtk-js-remoteview-example-get-any-widget-interaction/6157/7 "2021-10-21T15:36:51Z")

</div>

What did you do to resolve this issue? I also followed the example from [vtk.js](https://kitware.github.io/vtk-js/examples/RemoteView.html)

The Python script stalls, I cannot rotate the cone or zoom.

Thank you,  
Bernhard

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [October 21, 2021, 6:03pm UTC](https://discourse.vtk.org/t/vtk-js-remoteview-example-get-any-widget-interaction/6157/8 "2021-10-21T18:03:14Z")

</div>

Which version of VTK are you using?

---

<div class="post-metadata">

### Author: ![bernland](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/b19c9b/32.png) [@bernland](https://discourse.vtk.org/u/bernland)
#### Post date: [October 21, 2021, 8:22pm UTC](https://discourse.vtk.org/t/vtk-js-remoteview-example-get-any-widget-interaction/6157/9 "2021-10-21T20:22:46Z")

</div>

VTK 9.0.3 (installed through pip) and Python 3.8  
@kitware/vtk.js 20.1.0 (installed through npm)

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [October 21, 2021, 8:56pm UTC](https://discourse.vtk.org/t/vtk-js-remoteview-example-get-any-widget-interaction/6157/10 "2021-10-21T20:56:01Z")

</div>

Can you start your own thread describing your issue. I’m guessing it is just running the example as-is? Or are you editing the code with other stuff?

---

<div class="post-metadata">

### Author: ![bernland](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/b19c9b/32.png) [@bernland](https://discourse.vtk.org/u/bernland)
#### Post date: [November 2, 2021, 1:35pm UTC](https://discourse.vtk.org/t/vtk-js-remoteview-example-get-any-widget-interaction/6157/11 "2021-11-02T13:35:38Z")

</div>

After reading [Unable to get RemoteView outputs on client side](https://discourse.vtk.org/t/unable-to-get-remoteview-outputs-on-client-side/6944), I updated to the following version:

- Python 3.9
- VTK 9.1.0rc4

The example is now working, thank you for your support.
