[vtkusers] Multiple vtkTkRenderWidget in python

CHENET Aude (External) Aude.CHENET-ext at galderma.com
Mon Apr 11 11:25:24 EDT 2016


I’ve tried to add your code just before the call to vtkTkRenderWindowInteractor. And there is the same error invalid command name "vtkTkRenderWidget"
I’ve tried to call tk.call('vtkTkRenderWidget', '.vtkwidget') with the tk object I already have in my code, and there is no error.
I’ll look to find if there are different tcl interpreter installed and used.

Aude

De : David Gobbi [mailto:david.gobbi at gmail.com]
Envoyé : lundi 11 avril 2016 17:06
À : CHENET Aude (External)
Cc : vtkusers at public.kitware.com
Objet : Re: [vtkusers] Multiple vtkTkRenderWidget in python

Hi Aude,

I suspect that, somehow, you end up with two separate tcl interpreters.
But I don't know how that would happen.  Try something else for me:

    import Tkinter
    root = Tkinter.Tk()
    from vtk.tk.vtkLoadPythonTkWidgets import vtkLoadPythonTkWidgets
    vtkLoadPythonTkWidgets(root)
    root.tk.call('vtkTkRenderWidget', '.vtkwidget')

If this prints '.vtkwidget' then you know that vtkTkRenderWidget exists.
If your program later says 'invalid command name "vtkTkRenderWidget"',
then that message must be coming from a different tcl interpreter.

 - David



On Mon, Apr 11, 2016 at 8:57 AM, CHENET Aude (External) <Aude.CHENET-ext at galderma.com<mailto:Aude.CHENET-ext at galderma.com>> wrote:
The version I use is 6.3.0.

I’ve tried what you’ve suggested, but didn’t work..

Aude

De : David Gobbi [mailto:david.gobbi at gmail.com<mailto:david.gobbi at gmail.com>]
Envoyé : lundi 11 avril 2016 16:50
À : CHENET Aude (External)
Cc : vtkusers at public.kitware.com<mailto:vtkusers at public.kitware.com>
Objet : Re: [vtkusers] Multiple vtkTkRenderWidget in python

Hi Aude,

What version of VTK are you using?

Can you try loading the vtkTkRederWidget binary model before opening the file dialog? For example, something like this:

    import Tkinter
    from vtk.tk.vtkLoadPythonTkWidgets import vtkLoadPythonTkWidgets
    vtkLoadPythonTkWidgets(Tkinter.Tk())

 - David




On Mon, Apr 11, 2016 at 5:38 AM, CHENET Aude (External) <Aude.CHENET-ext at galderma.com<mailto:Aude.CHENET-ext at galderma.com>> wrote:
Hi,

I’m using vtk with python and try to do the following program :
Choose a file using tkFileDialog (filepath = tkFileDialog.askopenfilename(title="Choisir une image",filetypes=[('tif files','.tif'),('tiff files','.tiff')]))
Show the image in a window (render_widget = vtkTkRenderWindowInteractor(renderer_frame,
                                                    rw=renWin, width=600,
                                                    height=500))

My program have the following error
Traceback (most recent call last):
  File "C:\Users\chenet-ext\workspace\OCT\src\afficheComplet.py", line 328, in <module>
    V = Viewer(filepath)#("D:\resultatsOCT\Didier Cheek01 b_reconstr.tif”)
  File "C:\Users\chenet-ext\workspace\OCT\src\afficheComplet.py", line 165, in __init__
    height=500)
  File "C:\Python27\Lib\site-packages\vtk\tk\vtkTkRenderWindowInteractor.py", line 70, in __init__
    Tkinter.Widget.__init__(self, master, 'vtkTkRenderWidget', cnf, kw)
  File "C:\Python27\Lib\lib-tk\Tkinter.py", line 2090, in __init__
    (widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: invalid command name "vtkTkRenderWidget"

The program runs normally if I don’t call tkFileDialog to choose the file. It seems like we can’t call tkFileDialog and then create a vtkTkRenderWindowInteractor
Does anyone have an idea?

Aude


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160411/6476f8e5/attachment-0001.html>


More information about the vtkusers mailing list