<div dir="ltr">Hi<div><br></div><div style>This works, but it also breaks compatibility with the other systems as</div><div style><br></div><div style><span style="font-family:arial,sans-serif;font-size:13px">vtk has no module named QVTKWidget.</span><br>
</div><div style><br></div><div style><font face="arial, sans-serif">So don't know what the best approach is here.</font></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Jan 5, 2013 at 8:43 PM, <span dir="ltr"><<a href="mailto:lindeval@dmat.ufrr.br" target="_blank">lindeval@dmat.ufrr.br</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Try this way, it worked here.<br>
<br>
<br>
from PyQt4.QtCore import *<br>
from PyQt4.QtGui import *<br>
import vtk<br>
#from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor<br>
import sys<br>
class Ui_MainWindow(QWidget):<br>
<div class="im"> def setupUi(self, MainWindow):<br>
MainWindow.setObjectName("MainWindow")<br>
MainWindow.resize(603, 553)<br>
</div> self.centralWidget = QWidget(MainWindow)<br>
self.vtkWidget = vtk.QVTKWidget(self.centralWidget)<br>
self.gridlayout = QGridLayout(self.centralWidget)<br>
#self.vtkWidget = QVTKRenderWindowInteractor(self.centralWidget)<br>
<div class="im"> self.gridlayout.addWidget(self.vtkWidget, 0, 0, 1, 1)<br>
MainWindow.setCentralWidget(self.centralWidget)<br>
<br>
</div>class SimpleView(QMainWindow):<br>
<div class="im"> def __init__(self, parent = None):<br>
</div><div class="im"> QMainWindow.__init__(self, parent)<br>
self.ui = Ui_MainWindow()<br>
self.ui.setupUi(self)<br>
</div> widget = self.ui.vtkWidget<br>
self.ren = vtk.vtkRenderer()<br>
renwin = widget.GetRenderWindow()<br>
renwin.AddRenderer(self.ren)<br>
<div><div class="h5"> iren = self.ui.vtkWidget.GetRenderWindow().GetInteractor()<br>
cube = vtk.vtkCubeSource()<br>
cube.SetXLength(200)<br>
cube.SetYLength(200)<br>
cube.SetZLength(200)<br>
cube.Update()<br>
cm = vtk.vtkPolyDataMapper()<br>
cm.SetInputConnection(cube.GetOutputPort())<br>
ca = vtk.vtkActor()<br>
ca.SetMapper(cm)<br>
self.ren.AddActor(ca)<br>
self.axesActor = vtk.vtkAnnotatedCubeActor();<br>
self.axesActor.SetXPlusFaceText('R')<br>
self.axesActor.SetXMinusFaceText('L')<br>
self.axesActor.SetYMinusFaceText('H')<br>
self.axesActor.SetYPlusFaceText('F')<br>
self.axesActor.SetZMinusFaceText('P')<br>
self.axesActor.SetZPlusFaceText('A')<br>
self.axesActor.GetTextEdgesProperty().SetColor(1,1,0)<br>
self.axesActor.GetTextEdgesProperty().SetLineWidth(2)<br>
self.axesActor.GetCubeProperty().SetColor(0,0,1)<br>
self.axes = vtk.vtkOrientationMarkerWidget()<br>
self.axes.SetOrientationMarker(self.axesActor)<br>
self.axes.SetInteractor(iren)<br>
self.axes.EnabledOn()<br>
self.axes.InteractiveOn()<br>
self.ren.ResetCamera()<br>
<br>
</div></div><div class="im">if __name__ == "__main__":<br>
app = QApplication(sys.argv)<br>
window = SimpleView()<br>
window.show()<br>
</div> app.exec_()<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
----- Mensagem original -----<br>
De: "Niels Linnemann" <<a href="mailto:ne.linnemann@gmail.com">ne.linnemann@gmail.com</a>><br>
Para: <a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br>
Enviadas: Sábado, 5 de Janeiro de 2013 14:39:34 GMT -04:00 Georgetown<br>
Assunto: [vtkusers] Python Qt4 Vtk (5.8/5.10.1) Ubuntu 12.04<br>
<div><div class="h5"><br>
<br>
<br>
Hi<br>
<br>
<br>
I've been struggling with this for a while now and don't seem to get any further.<br>
<br>
<br>
I have a Win 7 machine running the latest pythonxy release and a CentOS 6.3 machine using python 2.6, PyQt-4.6 and vtk 5.6.<br>
<br>
<br>
I'm embedding a VTK render window inside a QFrame.<br>
<br>
<br>
This example works on the other two machines.<br>
<br>
<br>
<br>
from PyQt4 import QtCore, QtGui<br>
<br>
<br>
from PyQt4.QtGui import QApplication<br>
<br>
import vtk<br>
<br>
from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor<br>
<br>
import sys<br>
<br>
<br>
<br>
class Ui_MainWindow(object):<br>
<br>
def setupUi(self, MainWindow):<br>
<br>
MainWindow.setObjectName("MainWindow")<br>
<br>
MainWindow.resize(603, 553)<br>
<br>
self.centralWidget = QtGui.QWidget(MainWindow)<br>
<br>
self.gridlayout = QtGui.QGridLayout(self.centralWidget)<br>
<br>
self.vtkWidget = QVTKRenderWindowInteractor(self.centralWidget)<br>
<br>
self.gridlayout.addWidget(self.vtkWidget, 0, 0, 1, 1)<br>
<br>
MainWindow.setCentralWidget(self.centralWidget)<br>
<br>
<br>
<br>
class SimpleView(QtGui.QMainWindow):<br>
<br>
<br>
<br>
def __init__(self, parent = None):<br>
<br>
QtGui.QMainWindow.__init__(self, parent)<br>
<br>
self.ui = Ui_MainWindow()<br>
<br>
self.ui.setupUi(self)<br>
<br>
self.ren = vtk.vtkRenderer()<br>
<br>
self.ui.vtkWidget.GetRenderWindow().AddRenderer(self.ren)<br>
<br>
iren = self.ui.vtkWidget.GetRenderWindow().GetInteractor()<br>
<br>
cube = vtk.vtkCubeSource()<br>
<br>
cube.SetXLength(200)<br>
<br>
cube.SetYLength(200)<br>
<br>
cube.SetZLength(200)<br>
<br>
cube.Update()<br>
<br>
cm = vtk.vtkPolyDataMapper()<br>
<br>
cm.SetInputConnection(cube.GetOutputPort())<br>
<br>
ca = vtk.vtkActor()<br>
<br>
ca.SetMapper(cm)<br>
<br>
self.ren.AddActor(ca)<br>
<br>
self.axesActor = vtk.vtkAnnotatedCubeActor();<br>
<br>
self.axesActor.SetXPlusFaceText('R')<br>
<br>
self.axesActor.SetXMinusFaceText('L')<br>
<br>
self.axesActor.SetYMinusFaceText('H')<br>
<br>
self.axesActor.SetYPlusFaceText('F')<br>
<br>
self.axesActor.SetZMinusFaceText('P')<br>
<br>
self.axesActor.SetZPlusFaceText('A')<br>
<br>
self.axesActor.GetTextEdgesProperty().SetColor(1,1,0)<br>
<br>
self.axesActor.GetTextEdgesProperty().SetLineWidth(2)<br>
<br>
self.axesActor.GetCubeProperty().SetColor(0,0,1)<br>
<br>
self.axes = vtk.vtkOrientationMarkerWidget()<br>
<br>
self.axes.SetOrientationMarker(self.axesActor)<br>
<br>
self.axes.SetInteractor(iren)<br>
<br>
self.axes.EnabledOn()<br>
<br>
self.axes.InteractiveOn()<br>
<br>
self.ren.ResetCamera()<br>
<br>
iren.Initialize()<br>
<br>
<br>
<br>
<br>
<br>
<br>
if __name__ == "__main__":<br>
<br>
<br>
<br>
app = QApplication(sys.argv)<br>
<br>
window = SimpleView()<br>
<br>
window.show()<br>
sys.exit(app.exec_())<br>
<br>
<br>
On the Ubuntu machine no window pops up.<br>
I have 2 machines with very different hardware and same result.<br>
<br>
<br>
Commenting the "iren.Initialize()" line will make the window show, but no render.<br>
<br>
<br>
I have tried using the built-in ubuntu vtk python wrapping (5.8) package.<br>
I have compiled both vtk 5.8 and 5.10.1 from source, but same result (removed the default package before).<br>
<br>
<br>
The challenge I'm facing is that I get absolutely no error messages or debug info that I can work with.<br>
<br>
<br>
I'm on the verge on giving up on Ubuntu on this issue.<br>
<br>
<br>
Does anyone have anything I could try before I reformat to another distro?<br>
<br>
<br>
<br>
<br>
</div></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>