How to access to a plugin properties panel?


I would like to develop a plugin based on VTKPythonAlgorithmBase.
This plugin take as input a vtkDataset and 3 coordinates representing the position of a camera.

With the following code, I’ve managed to expose these 3 coordinates in Paraview’s properties panel:

    @smproperty.doublevector(name="Camera", default_values=[1, 1, 1], label="Camera")
    def Set1_Camera(self, x, y, z):
        value = np.r_[x, y, z]
        if not np.allclose(self._camera, value) :
            self._camera = value

I also succeed in adding a button which prints the position of the camera in the output window:

    @smproperty.xml('''<Property name="Print Camera Position" command="CameraButton" panel_widget="command_button"></Property>''')
    def CameraButton(self, *args):
        import paraview.simple
        camera = paraview.simple.GetActiveCamera()
        print('Camera position : ', camera.GetPosition())  

Instead of printing the camera position in the output window, I would like to fill the properties panel with these values.
How can I access to theses properties from the CameraButton function ?

Thanks for your help,



This is incorrect! One should not access paraview.simple module in the algorithms like so. I won’t go into details, but this is a big no-no in client-server configurations.

There’s no way to support this the way you’re implementing. The only reasonable solution would be add a custom property widget for the SetCamera property that then uses a custom pqPropertyWidget subclass that can access the active view and camera from the client side and then set the value to it. That will require C++ code, however, and cannot be done simply in VTKPythonAlgorithmBase subclass.

1 Like