Hi, everyone
I am writing a simple GUI with simple inputs and vtk rendering in Python. One article about this is combing tk and vtk, namely vtkTkRenderWindowInteractor, the error and code is as below:
(1) Error-------------------------------------------------------
TclError Traceback (most recent call last)
in
22 # Setup for rendering window interactor
23 renWinInteract = vtkTkRenderWindowInteractor(root,
—> 24 rw=renWindow, width=400, height=400)
25 renWinInteract.Initialize()
26 renWinInteract.pack(side=‘top’, fill=‘both’, expand=1)
~/anaconda2/envs/py3/lib/python3.6/site-packages/vtkmodules/tk/vtkTkRenderWindowInteractor.py in init(self, master, cnf, **kw)
53 “”"
54 # load the necessary extensions into tk
—> 55 vtkLoadPythonTkWidgets(master.tk)
56
57 try: # check to see if a render window was specified
~/anaconda2/envs/py3/lib/python3.6/site-packages/vtkmodules/tk/vtkLoadPythonTkWidgets.py in vtkLoadPythonTkWidgets(interp)
85
86 # re-generate the error
—> 87 interp.call(‘load’, filename, pkgname)
TclError Traceback (most recent call last)
in
22 # Setup for rendering window interactor
23 renWinInteract = vtkTkRenderWindowInteractor(root,
—> 24 rw=renWindow, width=400, height=400)
25 renWinInteract.Initialize()
26 renWinInteract.pack(side=‘top’, fill=‘both’, expand=1)
~/anaconda2/envs/py3/lib/python3.6/site-packages/vtkmodules/tk/vtkTkRenderWindowInteractor.py in init(self, master, cnf, **kw)
53 “”"
54 # load the necessary extensions into tk
—> 55 vtkLoadPythonTkWidgets(master.tk)
56
57 try: # check to see if a render window was specified
~/anaconda2/envs/py3/lib/python3.6/site-packages/vtkmodules/tk/vtkLoadPythonTkWidgets.py in vtkLoadPythonTkWidgets(interp)
85
86 # re-generate the error
—> 87 interp.call(‘load’, filename, pkgname)
TclError: dlopen(libvtkRenderingPythonTkWidgets-8.2.dylib, 6): image not found
(2) Code-------------------------------------------------------
import tkinter
import sys
import vtk
from vtk.tk.vtkTkRenderWindowInteractor import vtkTkRenderWindowInteractor
Setup for root window
root = tkinter.Tk()
root.title( “Tkinter Test” )
frame = tkinter.Frame( root )
frame.pack( fill=tkinter.BOTH, expand=1, side=tkinter.TOP )
Setup for renderer
render = vtk.vtkRenderer()
render.SetBackground( 0.329412, 0.34902, 0.427451 )
render.ResetCameraClippingRange()
Setup for rendering window
renWindow = vtk.vtkRenderWindow()
renWindow.AddRenderer(render)
Setup for rendering window interactor
renWinInteract = vtkTkRenderWindowInteractor(root,
rw=renWindow, width=400, height=400)
renWinInteract.Initialize()
renWinInteract.pack(side=‘top’, fill=‘both’, expand=1)
renWinInteract.Start()
Begin execution by updating the renderer and
starting the Tkinter loop
renWindow.Render()
root.mainloop()
(3) Other information-------------------------------------------------------
vtk: 8.2.0
python: 3.6
os: macOS
Any solution to this?
Many thanks.