<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello 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 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 class="Apple-style-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; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div>------------------------------------------------------</div><div>Eric E Monson</div><div>Duke Visualization Technology Group</div><div><br class="webkit-block-placeholder"></div></span></div><div><br class="webkit-block-placeholder"></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 class="Apple-tab-span" style="white-space:pre">        </span>def setupUi(self, MainWindow):</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>MainWindow.setObjectName("MainWindow")</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>MainWindow.resize(400, 400)</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>self.centralWidget = QtGui.QWidget(MainWindow)</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>self.gridlayout = QtGui.QGridLayout(self.centralWidget)</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>self.vtkWidget = vtk.QVTKWidget(self.centralWidget)</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>self.gridlayout.addWidget(self.vtkWidget, 0, 0, 1, 1)</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>MainWindow.setCentralWidget(self.centralWidget)</div><div><br></div><div>class SimpleView(QtGui.QMainWindow):</div><div> </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>def __init__(self, parent = None):</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>QtGui.QMainWindow.__init__(self, parent)</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>self.ui = Ui_MainWindow() </div><div><span class="Apple-tab-span" style="white-space:pre">                </span>self.ui.setupUi(self)</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>widget = self.ui.vtkWidget</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ren = vtk.vtkRenderer()</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>renwin = widget.GetRenderWindow()</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>renwin.AddRenderer(ren)</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>cone = vtk.vtkConeSource()</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>mapper = vtk.vtkPolyDataMapper()</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>mapper.SetInputConnection(cone.GetOutputPort())</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>actor = vtk.vtkActor()</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>actor.SetMapper(mapper)</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ren.AddViewProp(actor)</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ren.ResetCamera()</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span></div><div>if __name__ == "__main__":</div><div><br></div><div> app = QtGui.QApplication(sys.argv)</div><div> window = SimpleView()</div><div> window.show()</div><div> sys.exit(app.exec_())</div></div><div><br></div>
<br><div><div>On Nov 3, 2010, at 6:18 AM, Jothy wrote:</div><br class="Apple-interchange-newline"><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"><<a href="mailto:prathameshmkulkarni@gmail.com">prathameshmkulkarni@gmail.com</a>></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; position: static; z-index: auto; "><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. <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">www.kitware.com</a><br><br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">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">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">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></blockquote></div><br></div></body></html>