<div dir="ltr"><br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Adam Stylinski</b> <span dir="ltr">&lt;<a href="mailto:stylinae@mail.uc.edu">stylinae@mail.uc.edu</a>&gt;</span><br>
Date: Mon, Nov 28, 2011 at 3:59 PM<br>Subject: Re: [vtkusers] QVTKWidget in Python ?<br>To: Jothybasu Selvaraj &lt;<a href="mailto:jothybasu@gmail.com">jothybasu@gmail.com</a>&gt;<br><br><br><div class="HOEnZb"><div class="h5">
<br><br><div class="gmail_quote">On Mon, Nov 28, 2011 at 10:48 AM, Jothybasu Selvaraj <span dir="ltr">&lt;<a href="mailto:jothybasu@gmail.com" target="_blank">jothybasu@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">

<div dir="ltr">Here is the working code<br><br>import sys<div><br>from PyQt4 import QtCore, QtGui<br>from PyQt4.QtGui import *<br>from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor<br>import vtk<br>

<br>class MainWindow(QtGui.QMainWindow):<br>
    def __init__(self, parent = None):<br>        super(MainWindow, self).__init__(parent)<br>        self.initUI()<br><br>    def initUI(self):<br></div>       widget = QVTKRenderWindowInteractor()<br>       widget.Initialize()<br>


       widget.Start()<br>##       widget.AddObserver(&quot;ExitEvent&quot;, lambda o, e, a=app: a.quit())<div><br><br>       ren = vtk.vtkRenderer()<br>       widget.GetRenderWindow().AddRenderer(ren)<br><br>       cone = vtk.vtkConeSource()<br>


       cone.SetResolution(24)<br><br>       coneMapper = vtk.vtkPolyDataMapper()<br>       coneMapper.SetInput(cone.GetOutput())<br><br>       coneActor = vtk.vtkActor()<br>       coneActor.SetMapper(coneMapper)<br>       ren.AddActor(coneActor)<br>


       widget.show()<br><br>       <br><br></div>if __name__ == &quot;__main__&quot;:<br>    app=QApplication(sys.argv)<br>    form=MainWindow()<br>    app.exec_()<br><br>Jothy<div><div></div><div><br><br><div class="gmail_quote">

On Mon, Nov 28, 2011 at 3:33 PM, chasank <span dir="ltr">&lt;<a href="mailto:chasank@gmail.com" target="_blank">chasank@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">What&#39;s the wrong with below script? It just shows a blank window, where is<br>
the interactor window?<br>
Can anyone help me?<br>
<br>
import sys<br>
from Nifti import Nifti<br>
from PyQt4 import QtCore, QtGui<br>
from PyQt4.QtGui import *<br>
from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor<br>
import vtk<br>
<br>
class MainWindow(QtGui.QMainWindow):<br>
<br>
  def __init__(self, parent = None):<br>
    super(MainWindow, self).__init__(parent)<br>
    self.initUI()<br>
<br>
  def initUI(self):<br>
<br>
    widget = QVTKRenderWindowInteractor(self)<br>
    widget.Initialize()<br>
    widget.Start()<br>
    widget.AddObserver(&quot;ExitEvent&quot;, lambda o, e, a=app: a.quit())<br>
<br>
    ren = vtk.vtkRenderer()<br>
    widget.GetRenderWindow().AddRenderer(ren)<br>
<br>
    cone = vtk.vtkConeSource()<br>
    cone.SetResolution(24)<br>
<br>
    coneMapper = vtk.vtkPolyDataMapper()<br>
    coneMapper.SetInput(cone.GetOutput())<br>
<br>
    coneActor = vtk.vtkActor()<br>
    coneActor.SetMapper(coneMapper)<br>
    ren.AddActor(coneActor)<br>
    widget.show()<br>
<br>
    layout = QVBoxLayout()<br>
    layout.addWidget(widget)<br>
<br>
    central = QWidget()<br>
    central.setLayout(layout)<br>
<br>
    self.setCentralWidget(central)<br>
    self.setWindowTitle(&#39;Example&#39;)<br>
    self.show()<br>
<span><font color="#888888"><br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/QVTKWidget-in-Python-tp5024567p5029176.html" target="_blank">http://vtk.1045678.n5.nabble.com/QVTKWidget-in-Python-tp5024567p5029176.html</a><br>
</font></span><div><div>Sent from the VTK - Users mailing list archive at Nabble.com.<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>
</div></div></blockquote></div><br><br clear="all"><br></div></div><font color="#888888">-- <br><div dir="ltr">Jothy<br></div><br>
</font></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></div><div>Ah, guess you were missing the QT event loop.  The way to use python bindings+QT bindings with VTK may very well be different from C++.  Strange that you had any window at all without app.exec().</div>

<div> My stent with PyQt was pretty brief.</div>
</div><br><br clear="all"><br>-- <br><div dir="ltr">Jothy<br></div><br>
</div>