Sorry, want to correct myself.<div><br></div><div>When the above code is run, no error occurs at the command line, but a window comes up saying &quot;vtkpython.exe has stopped working&quot;. The way I run the code is in command line, using the vtkpython exe. </div>

<div><br></div><div>If I instead, change the red line to: </div><div>  <span class="Apple-style-span" style="font-family: &#39;courier new&#39;; font-size: 10px; "><span class="Apple-style-span" style="background-color: rgb(255, 204, 102);">QtCore.QObject.connect(self.</span><span class="Apple-style-span" style="background-color: rgb(255, 204, 102);">ui.button_importMesh, QtCore.SIGNAL(&quot;clicked()&quot;), displayMesh)</span></span></div>

<div><br>that is, removing the VTKGraphics part, which is the class name, then the error says that displayMesh is not defined.</div><div><br></div><div>Regards,</div><div>Helvin </div><div><br></div><div>p.s Please help!</div>

<div><br></div><div><br><div class="gmail_quote">On Thu, Aug 20, 2009 at 7:37 PM, Helvin Lui <span dir="ltr">&lt;<a href="mailto:helvinlui@gmail.com">helvinlui@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hi,<div><br></div><div>I wanted to use a slot which has been defined in another .py file. (The slot is called displayMesh, defined in a class called &quot;VTKGraphics&quot;, in a file called &quot;vtkGraphics.py&quot;) </div>


<div>However, when I try to connect the slot to a button in my gui, an error comes up: &quot;NameError: global name &#39;displayMesh&#39; is not defined. Am I importing the VTKGraphics class wrongly? I have included the beginning of each file below.</div>


<div><br></div><div>The main file is like this:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><font face="&#39;courier new&#39;, monospace"><span style="font-size:small">import sys, os, tempfile<br>


from PyQt4 import QtCore, QtGui, QtOpenGL<br>from ui0 import Ui_main<br># Import the VTKGraphics Class from the file called vtkGraphics.py<br><span style="background-color:rgb(255, 255, 51)">from vtkGraphics import VTKGraphics</span><br>


<br>class StartMain(QtGui.QMainWindow):<br></span></font><span style="white-space:pre"><font face="&#39;courier new&#39;, monospace"><span style="font-size:small">        </span></font></span><font face="&#39;courier new&#39;, monospace"><span style="font-size:small"><br>


</span></font><span style="white-space:pre"><font face="&#39;courier new&#39;, monospace"><span style="font-size:small">        </span></font></span><font face="&#39;courier new&#39;, monospace"><span style="font-size:small">def __init__(self, parent=None):<br>


</span></font><span style="white-space:pre"><font face="&#39;courier new&#39;, monospace"><span style="font-size:small">                </span></font></span><font face="&#39;courier new&#39;, monospace"><span style="font-size:small">QtGui.QWidget.__init__(self, parent)<br>


</span></font><span style="white-space:pre"><font face="&#39;courier new&#39;, monospace"><span style="font-size:small">                </span></font></span><font face="&#39;courier new&#39;, monospace"><span style="font-size:small">self.ui = Ui_main()<br>


</span></font><span style="white-space:pre"><font face="&#39;courier new&#39;, monospace"><span style="font-size:small">                </span></font></span><font face="&#39;courier new&#39;, monospace"><span style="font-size:small">self.ui.setupUi(self)<br>


</span></font><span style="white-space:pre"><font face="&#39;courier new&#39;, monospace"><span style="font-size:small">                </span></font></span><font face="&#39;courier new&#39;, monospace"><span style="font-size:small"># Here I want to connect the clicked signal of button_importMesh to the slot called displayMesh. But an error occurs here.<br>


</span></font><span style="white-space:pre"><font face="&#39;courier new&#39;, monospace"><span style="font-size:small">                </span></font></span><font face="&#39;courier new&#39;, monospace"><span style="font-size:small"><span style="background-color:rgb(255, 204, 204)">QtCore.QObject.connect(self.ui.button_importMesh, QtCore.SIGNAL(&quot;clicked()&quot;), VTKGraphics.displayMesh)</span><br>


<br># etc...</span></font></blockquote><div><font face="&#39;courier new&#39;" size="2"><span style="font-size:10px"><br></span></font><br></div><div>My vtkGraphics.py file:</div>
<div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><font face="&#39;courier new&#39;, monospace"><span style="font-size:small">from PyQt4 import QtCore<br>
<br><span style="background-color:rgb(255, 255, 51)">class VTKGraphics(QtCore.QObject)</span>:<br><br>    def <span style="background-color:rgb(255, 255, 51)">displayMesh</span>(self):    <br>
        import vtk<br>       <br>        with open(&#39;C:\\Qt\\SimLCM\\Default\\Data_Input_Geometry.txt&#39;, &#39;r&#39;) as f:   <br>            meshPoints = vtk.vtkPoints()<br>            aMesh = vtk.vtkVoxel()</span></font></blockquote>


<div><div>        </div><div>          # etc...</div><div><br></div><div><br></div><div>I have searched around for quite a bit, but could not find the solution. </div><div>Thanks so much guys,</div></div><div>-- <br>Helvin <br>


<br>&quot;Though the world may promise me more, I&#39;m just made to be filled with the Lord.&quot;<br>
</div>
</blockquote></div><br><br clear="all"><br>-- <br>Helvin <br><br>&quot;Though the world may promise me more, I&#39;m just made to be filled with the Lord.&quot;<br>
</div>