<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I think in your case, then, you might want to just have Jothy help you get the QVTKRenderWindowInteractor working. (I still use it for many of my projects, too.) To get the true Python-wrapped QVTKWidget you need to build the git (development) version of VTK with&nbsp;VTK_WRAP_PYTHON_SIP turned ON (for which you need sip and maybe other dependencies). After you build it all, the widget is loaded as part of vtk/qvtk.py, which loads the QVTKPython library.<div><br></div><div>Good luck,</div><div>-Eric</div><div><br></div><div><br><div><div>On Nov 3, 2010, at 11:49 AM, Prathamesh Kulkarni wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Thank you for the quick example.&nbsp;<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">&nbsp;</span><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br>
</span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">Quoting from my previous mail "I&nbsp;am using Python2.6 which comes with Pythonxy package. So I do not build VTK separately. It comes with Pythonxy too. Now, in the site_packages/vtk/qt I cannot find QVTKWidget. Also, in my separate build of VTK (with&nbsp;</span><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">VTK_WRAP_PYTHON set) I do not get QVTKWidget iniside bin/wrapping/python/vtk/qt. Where can I get it from?"</span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">When I run the example, I get the obvious error: 'AttributeError: 'module' object has no attribute 'QVTKWidget'. Meanwhile, I will try to see if QVTKRenderWindowInteractor works for me.</span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">- Prathamesh</span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br></span></div><div><br><div class="gmail_quote">On Wed, Nov 3, 2010 at 8:52 AM, Eric E. Monson <span dir="ltr">&lt;<a href="mailto:emonson@cs.duke.edu">emonson@cs.duke.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; "><div style="word-wrap:break-word">Hello&nbsp;Prathamesh,<div><br></div><div>Yes, it would help us diagnose your problems if you tell us which version of VTK you are using, on what platform, and whether you built it yourself (with&nbsp;VTK_WRAP_PYTHON_SIP: ON, which is required for the Python wrapping of QVTKWidget).</div>
<div><br></div><div>I've had some troubles with getting installed versions of VTK to work automatically with the SIP Python wrapped classes, so for now I just set my library path and pythonpath to directories in the build tree (this is with bash on OS X):</div>
<div><br></div><div>export VTK_DIR=/Users/emonson/Programming/VTK_git/VTK/build</div><div><div>export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${VTK_DIR}/bin</div><div>export PYTHONPATH=$PYTHONPATH:${VTK_DIR}/bin:${VTK_DIR}/Wrapping/Python</div>
<div><br></div><div>Once everything is built correctly and the paths are set, then import vtk.qvtk should work. I'll attach a simple example at the end in case you need a script example.</div><div><br></div><div>Also, just in case you didn't know, there is still the older QVTKRenderWindowInteractor which can be used to add a VTK render window to a PyQt app without building the SIP Python wrappers -- it's limited in a couple ways, but basically works fine for many applications.</div>
<div><br></div><div>Talk to you later,</div><div>-Eric</div><div><br></div><div>
<span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div>
------------------------------------------------------</div><div>Eric E Monson</div><div>Duke Visualization Technology Group</div><div><br></div></span></div><div><br></div><div># ==============================</div><div>
<div>from PyQt4 import QtCore, QtGui</div><div>import vtk</div><div>import sys</div><div><br></div><div>class Ui_MainWindow(object):</div><div><span style="white-space:pre-wrap">        </span>def setupUi(self, MainWindow):</div>
<div><span style="white-space:pre-wrap">                </span>MainWindow.setObjectName("MainWindow")</div><div><span style="white-space:pre-wrap">                </span>MainWindow.resize(400, 400)</div><div><span style="white-space:pre-wrap">                </span>self.centralWidget = QtGui.QWidget(MainWindow)</div>
<div><span style="white-space:pre-wrap">                </span>self.gridlayout = QtGui.QGridLayout(self.centralWidget)</div><div><span style="white-space:pre-wrap">                </span>self.vtkWidget = vtk.QVTKWidget(self.centralWidget)</div><div>
<span style="white-space:pre-wrap">                </span>self.gridlayout.addWidget(self.vtkWidget, 0, 0, 1, 1)</div><div><span style="white-space:pre-wrap">                </span>MainWindow.setCentralWidget(self.centralWidget)</div><div><br></div><div>
class SimpleView(QtGui.QMainWindow):</div><div>&nbsp;&nbsp; &nbsp;</div><div><span style="white-space:pre-wrap">        </span>def __init__(self, parent = None):</div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">                </span>QtGui.QMainWindow.__init__(self, parent)</div>
<div><span style="white-space:pre-wrap">                </span>self.ui = Ui_MainWindow()&nbsp;</div><div><span style="white-space:pre-wrap">                </span>self.ui.setupUi(self)</div><div><span style="white-space:pre-wrap">                </span></div><div><span style="white-space:pre-wrap">                </span>widget = self.ui.vtkWidget</div>
<div><span style="white-space:pre-wrap">                </span></div><div><span style="white-space:pre-wrap">                </span>ren = vtk.vtkRenderer()</div><div><span style="white-space:pre-wrap">                </span>renwin = widget.GetRenderWindow()</div>
<div><span style="white-space:pre-wrap">                </span>renwin.AddRenderer(ren)</div><div><span style="white-space:pre-wrap">                </span></div><div><span style="white-space:pre-wrap">                </span>cone = vtk.vtkConeSource()</div><div><span style="white-space:pre-wrap">                </span>mapper = vtk.vtkPolyDataMapper()</div>
<div><span style="white-space:pre-wrap">                </span>mapper.SetInputConnection(cone.GetOutputPort())</div><div><span style="white-space:pre-wrap">                </span>actor = vtk.vtkActor()</div><div><span style="white-space:pre-wrap">                </span>actor.SetMapper(mapper)</div>
<div><span style="white-space:pre-wrap">                </span></div><div><span style="white-space:pre-wrap">                </span>ren.AddViewProp(actor)</div><div><span style="white-space:pre-wrap">                </span>ren.ResetCamera()</div><div><span style="white-space:pre-wrap">                                </span></div>
<div>if __name__ == "__main__":</div><div><br></div><div>&nbsp;&nbsp; &nbsp;app = QtGui.QApplication(sys.argv)</div><div>&nbsp;&nbsp; &nbsp;window = SimpleView()</div><div>&nbsp;&nbsp; &nbsp;window.show()</div><div>&nbsp;&nbsp; &nbsp;sys.exit(app.exec_())</div></div><div>
<div></div><div class="h5"><div><br></div>
<br><div><div>On Nov 3, 2010, at 6:18 AM, Jothy wrote:</div><br><blockquote type="cite"><div dir="ltr">Which python bundle are you using and how are importing the QVTK?<br><br>One easiest option is to add the QVTKWidget into your working directory and import.<br>
<br>Jothy<br><br><div class="gmail_quote">On Wed, Nov 3, 2010 at 3:45 AM, Prathamesh Kulkarni <span dir="ltr">&lt;<a href="mailto:prathameshmkulkarni@gmail.com" target="_blank">prathameshmkulkarni@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin-top:0pt;margin-right:0pt;margin-bottom:0pt;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204, 204, 204);padding-left:1ex"><div dir="ltr">
Hello all,<br><br>I want to create a GUI using PyQt4 and display a vtkImage inside it. For that, I need to embed a QVTKWidget in my GUI. However, I get 'ImportError: No module named qvtk' when I do import vtk.qvtk as given in <a href="http://vtk.1045678.n5.nabble.com/about-vtk-python-bindings-and-Qt-td2841114i20.html" target="_blank">http://vtk.1045678.n5.nabble.com/about-vtk-python-bindings-and-Qt-td2841114i20.html</a> . I am confused about how to get started with this and did not find examples demonstrating this.&nbsp;<br>



<div><br></div><div>Please point me to the steps for writing this "hello world".</div><div><br></div><div>Thanks,</div><div>Prathamesh</div></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br><br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br></div></div></div></div></blockquote></div><br></div></div>
</blockquote></div><br></div></body></html>