VTK with tkinter

I am trying to combine VTK with tkinter. However I am getting following error.

_tkinter.TclError: couldn’t load library “vtkRenderingTk-9.0.dll”: this library or a dependent library could not be found in library path

I am trying to load vtkTkRenderWindowInteractor in this way:

from vtkmodules.tk.vtkTkRenderWindowInteractor import vtkTkRenderWindowInteractor

renWinInteract = vtkTkRenderWindowInteractor(root, rw=renWindow, width=400, height=400)

renWinInteract.Initialize()

renWinInteract.pack(side=‘top’, fill=‘both’, expand=1)

renWinInteract.Start()

renWindow.Render()

root.mainloop()

Thanks for any help.

1 Like

The vtkTkRenderWindowInteractor is no longer used nor regularly tested by any of the VTK developers. So unless you really need it you should probably not use it. But if you need it, here is some information about its use.

  1. The vtkRenderingTk-9.0.dll is not part of the binary VTK package (not in the package from the vtk website, and not in the pip package either).

  2. So if you want to use it, you must first build tcl-8.6.8 and tk8.6.8 from source, and then you must build VTK from source with VTK_USE_TK=ON.

  3. After the build, find “vtkRenderingTk-9.0.dll” in the bin directory, and move it into Python’s site-packages director.

Note that Step 3 might not be necessary. Try it both with, and without this step.

Thank you for your response David. I would rather avoid going through something that is not supported/used anymore. I would like to add some interface to my program such as the buttons. Which is the best way now to do it in python? Build all in VTK with Qt?

Thanks

For Python VTK in Qt, I have an example of VTK with PySide2. All you need to get started with this example is PySide2 (e.g. installed with pip) and a binary VTK package.

Note that VTK + PyQt and VTK + PySide are not “officially” supported, either, but quite a few people use them and get good results.

Thank you for your replay. I will have a look at this. However, there is something that is supported with VTK?

There are no GUI toolkits that are officially supported for VTK-Python.

I understand. Thank you.

Another option is trame with pywebview.