Hello VTKusers,<br><br>I had a problem regarding the use of the vtkTkRenderWidget in Python.<br>After a bit of googling I found more people have had this problem, but<br>could not find a solution on the web. <br><br>I now found the solution myself, and thought to reply to the original poster<br>

(see message below). That post is from december 2004 (thus 4 years old).<br><br>Although the VTK version is different (I use VTK 5.21) the problem is the same.<br>The problem is cause by the function vtkLoadPythonTkWidgets in module<br>

vtk.tk.vtkLoadPythonTkWidgets. That function has the following lines near the <br>top, that prevent the widget to be found a second time:<br>&nbsp;<br>&nbsp;&nbsp;&nbsp; # find out if the file is already loaded<br>&nbsp;&nbsp;&nbsp; loaded = interp.call(&#39;info&#39;, &#39;loaded&#39;)<br>

&nbsp;&nbsp;&nbsp; if string.find(loaded, pkgname) &gt;= 0:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pass#return <br><br>By simply replacing &quot;return&quot; with &quot;pass&quot; the problem is solved. <br><br>Cheers,<br>&nbsp; Almar<br><br><br>================ MESSAGE BY Alexandre Thinnes =============<br>

<br>I have some problems with management of many vtkTkRenderWidget.<br><br>I am developing GUI for surgical software in Python Language.<br>Each window of this GUI have one vtkTkRenderWidget to show 3D objects<br>(One of them use the vtkSliceWidget develop by Atamai).<br>

I succeed to show one object into one window.<br>But if I try to open another one I get this error:<br><br>File &quot;/usr/local/lib/python2.2/lib-tk/Tkinter.py&quot;, line 1316, in<br>__call__<br>    return apply(self.func, args)<br>

  File &quot;selection.py&quot;, line 64, in &lt;lambda&gt;<br>    command = lambda:<br>  File &quot;functionclass.py&quot;, line 550, in entranceTriplan<br>    self.show2(self.triplan)<br>  File &quot;functionclass.py&quot;, line 164, in show2<br>

    self.affichageTriplan(&quot;exemple.mnc&quot;)<br>  File &quot;functionclass.py&quot;, line 584, in affichageTriplan<br>    self.viewer1 =<br>vtkSliceWidget.vtkSliceWidget(self.triplan.frame1,width=256,height=256)<br>

  File &quot;/home/athinnes/atamai/examples/vtkSliceWidget.py&quot;, line 108, in<br>__init__<br>    Tkinter.Widget.__init__(self, master, &#39;vtkTkRenderWidget&#39;, cnf, kw)<br>  File &quot;/usr/local/lib/python2.2/lib-tk/Tkinter.py&quot;, line 1780, in<br>

__init__<br>    self.tk.call(<br>TclError: invalid command name &quot;vtkTkRenderWidget&quot;<br><br>This following is a simplify version of the software architecture<br>without using vtkSliceWidget .<br>Each module corresponding to one part of the interface ( Here there are<br>

4 modules ):<br><br>######################################################################<br>#testfunc.py<br><br>from Tkinter import *<br>from vtkTkRenderWidget import *<br>import triplantest<br>import bouton<br>import render<br>

<br>class Functions:<br><br>   def __init__(self, myParent):<br>      print &quot;functions class created&quot;<br># If you comment the self.render line. The button will open the<br>triplantest window<br>      self.render = render.Render(self, myParent)<br>

<br>      self.bouton = bouton.Bouton(self)<br>      self.triplan = triplantest.Triplan(self)<br><br>## Procedure:  show<br># this procedure is call to show on the screen the windows winname<br>   def show(self, winname):<br>

      winname.deiconify()<br>      self.affichageTriplan()<br><br>## Procedure:  affichageTriplan<br># This procedure setup the slice image inside triplan interface<br><br>   def affichageTriplan(self):<br><br>      self.renderWidget = vtkTkRenderWidget(self.triplan.frame1)<br>

      self.renderWidget.pack(expand=&#39;true&#39;,fill=&#39;both&#39;)<br><br><br>if __name__ == &#39;__main__&#39;:<br><br>   root = Tk()<br>   function = Functions(root)<br>   function.triplan.withdraw()<br>   root.mainloop()<br>

<br>#######################################################################<br>#render.py<br><br>from vtkTkRenderWidget import *<br>from vtkpython import *<br>from Tkinter import *<br><br>class Render:<br><br>   def __init__(self, myFunctions, myParentFunction):<br>

<br>      self.functions = myFunctions<br>      myParentFunction.title(&quot;test vtkTkRenderWidget&quot;)<br><br>      self.viewer = Frame(myParentFunction, borderwidth = 2, relief =<br>&quot;ridge&quot;)<br>      self.renderWidget = vtkTkRenderWidget(self.viewer)<br>

<br>      self.viewer.pack(expand=&#39;true&#39;,fill=&#39;both&#39;)<br>      self.renderWidget.pack(expand=&#39;true&#39;,fill=&#39;both&#39;)<br><br>##########################################################################<br>

<br>#triplantest.py<br><br>from Tkinter import *<br><br>class Triplan(Tk):<br>   def __init__(self, myFct):<br>      Tk.__init__(self)<br><br>      self.functions = myFct<br>      self.title(&quot;Frame for vtkSliceWidget&quot;)<br>

<br>      self.mainframe = Frame(self)<br>      self.frame1 = Frame(self.mainframe, relief=&quot;ridge&quot;, borderwidth=2)<br><br>      self.frame1.pack(expand=&#39;true&#39;,fill=&#39;both&#39;)<br>      self.mainframe.pack(expand=&#39;true&#39;,fill=&#39;both&#39;)<br>

<br>###############################################################<br>#bouton.py<br><br>from Tkinter import *<br>class Bouton(Tk):<br><br>   def __init__(self, myFunctions):<br>      Tk.__init__(self)<br>      self.functions = myFunctions<br>

      self.title(&quot;Click On Button&quot;)<br>      self.frame = Frame(self)<br>      self.bouton = Button(self.frame, text = &quot;click \nhere&quot;,<br>       command = lambda:<br>         self.functions.show(self.functions.triplan)<br>

      )<br><br>      self.frame.pack(expand=&#39;true&#39;,fill=&#39;both&#39;)<br>      self.bouton.pack(expand=&#39;true&#39;,fill=&#39;both&#39;)<br><br>######################################################################3<br>

<br>If you run &quot;python testfunc.py&quot; you will see the error. It&#39;s the same I<br>have in the full software.<br><br>Somebody have any idea why it&#39;s not working and how to solve it?<br>It seams, vtkTkRenderWidget cannot be call twice. But I don&#39;t know how<br>

to solve it.<br><br>Thank you for your attention<br>Best regards<br>Alexandre Thinnes<br><br>